Registrations: view to uncheck apply_reduced_fee while accepting
Some checks failed
buildbot/tox Build done.
Some checks failed
buildbot/tox Build done.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import datetime
|
||||
import logging
|
||||
import os
|
||||
from django.apps import apps
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth import login
|
||||
from django.contrib.auth.decorators import login_required
|
||||
@@ -271,30 +272,13 @@ class EventRegistrationsView(EventPermissionMixin, generic.DetailView):
|
||||
messages.success(request, _(u'Der Anmeldeschluss wurde gelöscht'))
|
||||
|
||||
def _accept_registration(self, request, registration):
|
||||
event = registration.event
|
||||
data = registration.get_data_dict()
|
||||
del data['created_at']
|
||||
del data['answered_obsolete']
|
||||
data['position'] = registration.event.participants.count() + 1
|
||||
|
||||
position = event.participants.count() + 1
|
||||
|
||||
data = {
|
||||
'event': event,
|
||||
'position': position,
|
||||
'personal_names': registration.personal_names,
|
||||
'family_names': registration.family_names,
|
||||
'address': registration.address,
|
||||
'postal_code': registration.postal_code,
|
||||
'city': registration.city,
|
||||
'email_address': registration.email_address,
|
||||
'year_of_birth': registration.year_of_birth,
|
||||
'apply_reduced_fee': registration.apply_reduced_fee,
|
||||
'phone_number': registration.phone_number,
|
||||
'dav_member': registration.dav_member,
|
||||
'dav_number': registration.dav_number,
|
||||
'emergency_contact': registration.emergency_contact,
|
||||
'experience': registration.experience,
|
||||
'note': registration.note,
|
||||
'purge_at': registration.purge_at,
|
||||
}
|
||||
participant = models.Participant.objects.create(**data)
|
||||
|
||||
registration.status.set_accepted()
|
||||
messages.success(request, _(u'Teilnehmer hinzugefügt: {}'.format(participant.get_full_name())))
|
||||
|
||||
@@ -455,6 +439,62 @@ class EventRegistrationsView(EventPermissionMixin, generic.DetailView):
|
||||
return super(EventRegistrationsView, self).dispatch(request, *args, **kwargs)
|
||||
|
||||
|
||||
class RespondRegistrationView(EventPermissionMixin, generic.DetailView, generic.FormView):
|
||||
permission = 'update-participants'
|
||||
context_object_name = 'registration'
|
||||
template_name = 'dav_events/registration_response.html'
|
||||
form_class = forms.registration.RegistrationResponseForm
|
||||
|
||||
def _accept_registration(self, request, registration):
|
||||
data = registration.get_data_dict()
|
||||
del data['created_at']
|
||||
del data['answered_obsolete']
|
||||
data['position'] = registration.event.participants.count() + 1
|
||||
|
||||
participant = models.Participant.objects.create(**data)
|
||||
|
||||
registration.status.set_accepted()
|
||||
messages.success(request, _(u'Teilnehmer hinzugefügt: {}'.format(participant.get_full_name())))
|
||||
|
||||
def has_permission(self, permission, obj):
|
||||
user = self.request.user
|
||||
return obj.event.workflow.has_permission(user, permission)
|
||||
|
||||
def get_queryset(self):
|
||||
model = apps.get_model(app_label='dav_registration', model_name='Registration')
|
||||
return model.objects.all()
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse('dav_events:registrations', args=[self.object.event.pk])
|
||||
|
||||
def get_initial(self):
|
||||
return {
|
||||
'apply_reduced_fee': self.object.apply_reduced_fee,
|
||||
}
|
||||
|
||||
def form_valid(self, form):
|
||||
registration = self.object
|
||||
registration.apply_reduced_fee = form.cleaned_data['apply_reduced_fee']
|
||||
registration.save()
|
||||
self._accept_registration(self.request, registration)
|
||||
return HttpResponseRedirect(self.get_success_url())
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
self.object = self.get_object()
|
||||
self.enforce_permission(self.object)
|
||||
context = self.get_context_data(object=self.object)
|
||||
return self.render_to_response(context)
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
self.object = self.get_object()
|
||||
self.enforce_permission(self.object)
|
||||
return super(RespondRegistrationView, self).post(request, *args, **kwargs)
|
||||
|
||||
@method_decorator(login_required)
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
return super(RespondRegistrationView, self).dispatch(request, *args, **kwargs)
|
||||
|
||||
|
||||
class EventUpdateStatusView(EventPermissionMixin, generic.DetailView):
|
||||
model = models.Event
|
||||
|
||||
|
||||
Reference in New Issue
Block a user