Skip to content
Snippets Groups Projects
Commit 89b61d27 authored by Tom Teichler's avatar Tom Teichler :beers:
Browse files

Add basic backend code

parent fedcb0f9
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@ from datetime import datetime
from decimal import Decimal
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ValidationError
from django.db import models
from django.urls import reverse
from django.utils.text import slugify
......@@ -280,6 +281,26 @@ class EventRegistration(ExtensibleModel):
RegistrationState, verbose_name=_("States"), related_name="registrations"
)
retracted = models.BooleanField(verbose_name=_("Retracted"), default=False)
@property
def retractable(self):
return datetime.today() < self.event.date_retraction
def retract(self):
if self.retractable:
# Remove person from group
self.linked_group.members.remove(self.person)
# Invoice
inv = self.get_invoice()
inv.for_object = None
inv.for_object_class = None
inv.save()
self.retraced = True
self.save()
else:
return ValidationError(_("Registration is not retractable!"))
def get_person(self):
return self.person
......
......@@ -72,6 +72,11 @@ urlpatterns = [
path("vouchers/", views.vouchers, name="vouchers"),
path("event/lists/generate", views.generate_lists, name="generate_lists"),
path("event/registrations/list", views.registrations, name="registrations"),
path(
"event/registrations/<int:pk>/retract",
views.registrations,
name="retract_registration_by_id",
),
path(
"event/registrations/<int:pk>",
views.EventRegistrationDetailView.as_view(),
......
......@@ -899,3 +899,10 @@ class RegistrationStateEditView(PermissionRequiredMixin, AdvancedEditView):
template_name = "paweljong/registration_state/edit.html"
success_url = reverse_lazy("registration_states")
success_message = _("The term has been saved.")
class RetractRegistration(View):
def get(self):
registration = EventRegistration.objects.get(id=self.kwargs["pk"])
registration.retract()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment