Added restore from trash feature
All checks were successful
buildbot/tox Build done.

This commit is contained in:
2020-12-03 15:50:47 +01:00
parent 94595f4785
commit 7624c3d69b
3 changed files with 92 additions and 33 deletions

View File

@@ -299,6 +299,11 @@ class EventRegistrationsView(EventPermissionMixin, generic.DetailView):
def _reject_registration(self, registration):
registration.rejected()
def _reset_registration(self, registration):
registration.status.accepted = None
registration.status.answered = False
registration.status.save()
def _swap_participants_position(self, participant1, participant2):
event = participant1.event
pos_tmp = event.participants.count() + 1
@@ -347,6 +352,14 @@ class EventRegistrationsView(EventPermissionMixin, generic.DetailView):
self._reject_registration(registration)
else:
raise FieldDoesNotExist('Event has no registrations')
elif action == 'untrash_registration':
self.enforce_permission(event, permission='update-registration')
if hasattr(event, 'registrations'):
registration_id = request.POST.get('registration')
registration = event.registrations.get(id=registration_id)
self._reset_registration(registration)
else:
raise FieldDoesNotExist('Event has no registrations')
elif action == 'confirm_payment':
self.enforce_permission(event, permission='payment')
participant_id = request.POST.get('id')
@@ -374,6 +387,18 @@ class EventRegistrationsView(EventPermissionMixin, generic.DetailView):
participant.save()
messages.success(request, _(u'Teilnehmer in den Papierkorb verschoben: {}'.format(trashed.get_full_name())))
elif action == 'untrash_participant':
self.enforce_permission(event, permission='update-participants')
trashed_id = request.POST.get('id')
trashed = event.trashed_participants.get(id=trashed_id)
trashed.position = event.participants.count() + 1
data = trashed.get_data_dict()
del data['trashed_at']
participant = models.Participant.objects.create(**data)
trashed.delete()
messages.success(request, _(u'Teilnehmer zurückgeholt: {}'.format(participant.get_full_name())))
elif action == 'moveup_participant':
self.enforce_permission(event, permission='update-participants')
participant_id = request.POST.get('id')