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

@@ -175,13 +175,16 @@
{% with position=participant.position %}
<div class="panel {% if event.max_participants and position > event.max_participants %}panel-warning{% else %}panel-default{% endif %}">
<div id="headingParticipant_{{ participant.id }}" class="panel-heading" role="tab">
<h5 class="panel-title">
<a role="button" href="#collapseParticipant_{{ participant.id }}"
data-toggle="collapse"
aria-expanded="true" aria-controls="collapseParticipant_{{ participant.id }}">
<span class="caret"></span>&nbsp;&nbsp;
{{ position }}. {{ participant.get_full_name }}
</a>
<div>
<strong><span class="panel-title">
<a role="button" href="#collapseParticipant_{{ participant.id }}"
data-toggle="collapse"
aria-expanded="true" aria-controls="collapseParticipant_{{ participant.id }}">
<span class="caret"></span>&nbsp;&nbsp;
{{ position }}. {{ participant.get_full_name }}
</a>
</span></strong>
&nbsp;
<small>
(<a href="mailto:{{ participant.email_address }}">{{ participant.email_address }}</a>, {{ participant.phone_number }})
</small>
@@ -249,7 +252,7 @@
{% endif %}
</form>
</div>
</h5>
</div>
</div>
<div id="collapseParticipant_{{ participant.id }}"
class="panel-collapse collapse {% if form.errors %}in{% endif %}"

View File

@@ -344,13 +344,16 @@ Wichtig: das System verschickt keine Bestätigung an dich oder den neuen Teilneh
{% with position=participant.position %}
<div class="panel {% if event.max_participants and position > event.max_participants %}panel-warning{% else %}panel-default{% endif %}">
<div id="headingParticipant_{{ participant.id }}" class="panel-heading" role="tab">
<h5 class="panel-title">
<a role="button" href="#collapseParticipant_{{ participant.id }}"
data-toggle="collapse"
aria-expanded="true" aria-controls="collapseParticipant_{{ participant.id }}">
<span class="caret"></span>&nbsp;&nbsp;
{{ position }}. {{ participant.get_full_name }}
</a>
<div>
<strong><span class="panel-title">
<a role="button" href="#collapseParticipant_{{ participant.id }}"
data-toggle="collapse"
aria-expanded="true" aria-controls="collapseParticipant_{{ participant.id }}">
<span class="caret"></span>&nbsp;&nbsp;
{{ position }}. {{ participant.get_full_name }}
</a>
</span></strong>
&nbsp;
<small>
(<a href="mailto:{{ participant.email_address }}">{{ participant.email_address }}</a>, {{ participant.phone_number }})
</small>
@@ -412,7 +415,7 @@ Wichtig: das System verschickt keine Bestätigung an dich oder den neuen Teilneh
{% endif %}
</form>
</div>
</h5>
</div>
</div>
<div id="collapseParticipant_{{ participant.id }}"
class="panel-collapse collapse {% if form.errors %}in{% endif %}"
@@ -459,7 +462,7 @@ Wichtig: das System verschickt keine Bestätigung an dich oder den neuen Teilneh
<hr />
<div class="pull-right text-info" style="margin-right: 1em;"
title="Wenn du Anmeldungen mit einem Klick auf das Plus- oder Minus-Symbol 'bearbeitest', oder Teilnehmer aus der Teilnehmerliste entfernst, dann kann man diese Einträge noch im Papierkorb sehen (herausholen kann sie im Moment aber nur heinzel).
title="Wenn du Anmeldungen mit einem Klick auf das Plus- oder Minus-Symbol 'bearbeitest', oder Teilnehmer aus der Teilnehmerliste entfernst, dann sind diese Einträge danach noch im Papierkorb zu finden.
">
{% bootstrap_icon 'question-sign' %}
</div>
@@ -486,12 +489,18 @@ Wichtig: das System verschickt keine Bestätigung an dich oder den neuen Teilneh
{% for registration in registrations_answered %}
<div>
<button disabled="disabled"
class="btn btn-link no-padding" title="Anmeldung wurde bereits bearbeitet">
class="btn btn-link no-padding" title="Bei dieser Anmeldung hast du bereits
am {{ registration.status.updated_at|date:'d. F Y, G:i' }}
auf {% if registration.status.accepted %}Plus{% else %}Minus{% endif %} geklickt.
">
<span class="{% if registration.status.accepted %}text-success{% else %}text-muted{% endif %}">{% bootstrap_icon 'plus-sign' %}</span>
</button>
&nbsp;
<button disabled="disabled"
class="btn btn-link no-padding" title="Anmeldung wurde bereits bearbeitet">
class="btn btn-link no-padding" title="Bei dieser Anmeldung hast du bereits
am {{ registration.status.updated_at|date:'d. F Y, G:i' }}
auf {% if registration.status.accepted %}Plus{% else %}Minus{% endif %} geklickt.
">
<span class="{% if not registration.status.accepted %}text-danger{% else %}text-muted{% endif %}">{% bootstrap_icon 'minus-sign' %}</span>
</button>
&nbsp;
@@ -509,13 +518,20 @@ Wichtig: das System verschickt keine Bestätigung an dich oder den neuen Teilneh
{% bootstrap_icon 'info-sign' %}
</span>
</span>
&nbsp;
<span class="text-info" title="Bei dieser Anmeldung hast du bereits
am {{ registration.status.updated_at|date:'d. F Y, G:i' }}
auf {% if registration.status.accepted %}Plus{% else %}Minus{% endif %} geklickt.
">
{% bootstrap_icon 'question-sign' %}
</span>
{% if has_permission_update_registration %}
<div class="pull-right">
<form action="" method="post" class="form-inline">
{% csrf_token %}
<input type="hidden" name="registration" value="{{ registration.id }}">
<button type="submit" name="action" value="untrash_registration"
class="btn btn-link no-padding"
title="{% trans 'Eintrag in Anmeldungen zurückholen' %}">
<span class="text-danger">{% bootstrap_icon 'repeat' %}</span>
</button>
</form>
</div>
{% endif %}
</div>
{% endfor %}
</div>
@@ -541,6 +557,14 @@ auf {% if registration.status.accepted %}Plus{% else %}Minus{% endif %} geklickt
<div class="panel-body">
{% for participant in participants_trash %}
<div>
<button disabled="disabled"
class="btn btn-link no-padding" title="Diesen Teilnehmer hast du
am {{ participant.trashed_at|date:'d. F Y, G:i' }}
von Position {{ participant.position }} der Teilnehmerliste entfernt.
">
<span class="text-danger">{% bootstrap_icon 'trash' %}</span>
</button>
&nbsp;
<span class="text-muted">
{{ participant.get_full_name }}
(<a href="mailto:{{ participant.email_address }}">{{ participant.email_address }}</a>,
@@ -562,13 +586,20 @@ auf {% if registration.status.accepted %}Plus{% else %}Minus{% endif %} geklickt
</span>
{% endif %}
</span>
&nbsp;
<span class="text-info" title="Diesen Teilnehmer hast du
am {{ participant.trashed_at|date:'d. F Y, G:i' }}
von Position {{ participant.position }} der Teilnehmerliste entfernt.
">
{% bootstrap_icon 'question-sign' %}
</span>
{% if has_permission_update_participants %}
<div class="pull-right">
<form action="" method="post" class="form-inline">
{% csrf_token %}
<input type="hidden" name="id" value="{{ participant.id }}">
<button name="action" value="untrash_participant"
title="{% trans 'Eintrag in Teilnehmerliste zurückholen' %}"
class="btn btn-link no-padding">
<span class="text-danger">{% bootstrap_icon 'repeat' %}</span>
</button>
</form>
</div>
{% endif %}
</div>
{% endfor %}
</div>

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')