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 %} {% with position=participant.position %}
<div class="panel {% if event.max_participants and position > event.max_participants %}panel-warning{% else %}panel-default{% endif %}"> <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"> <div id="headingParticipant_{{ participant.id }}" class="panel-heading" role="tab">
<h5 class="panel-title"> <div>
<strong><span class="panel-title">
<a role="button" href="#collapseParticipant_{{ participant.id }}" <a role="button" href="#collapseParticipant_{{ participant.id }}"
data-toggle="collapse" data-toggle="collapse"
aria-expanded="true" aria-controls="collapseParticipant_{{ participant.id }}"> aria-expanded="true" aria-controls="collapseParticipant_{{ participant.id }}">
<span class="caret"></span>&nbsp;&nbsp; <span class="caret"></span>&nbsp;&nbsp;
{{ position }}. {{ participant.get_full_name }} {{ position }}. {{ participant.get_full_name }}
</a> </a>
</span></strong>
&nbsp;
<small> <small>
(<a href="mailto:{{ participant.email_address }}">{{ participant.email_address }}</a>, {{ participant.phone_number }}) (<a href="mailto:{{ participant.email_address }}">{{ participant.email_address }}</a>, {{ participant.phone_number }})
</small> </small>
@@ -249,7 +252,7 @@
{% endif %} {% endif %}
</form> </form>
</div> </div>
</h5> </div>
</div> </div>
<div id="collapseParticipant_{{ participant.id }}" <div id="collapseParticipant_{{ participant.id }}"
class="panel-collapse collapse {% if form.errors %}in{% endif %}" 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 %} {% with position=participant.position %}
<div class="panel {% if event.max_participants and position > event.max_participants %}panel-warning{% else %}panel-default{% endif %}"> <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"> <div id="headingParticipant_{{ participant.id }}" class="panel-heading" role="tab">
<h5 class="panel-title"> <div>
<strong><span class="panel-title">
<a role="button" href="#collapseParticipant_{{ participant.id }}" <a role="button" href="#collapseParticipant_{{ participant.id }}"
data-toggle="collapse" data-toggle="collapse"
aria-expanded="true" aria-controls="collapseParticipant_{{ participant.id }}"> aria-expanded="true" aria-controls="collapseParticipant_{{ participant.id }}">
<span class="caret"></span>&nbsp;&nbsp; <span class="caret"></span>&nbsp;&nbsp;
{{ position }}. {{ participant.get_full_name }} {{ position }}. {{ participant.get_full_name }}
</a> </a>
</span></strong>
&nbsp;
<small> <small>
(<a href="mailto:{{ participant.email_address }}">{{ participant.email_address }}</a>, {{ participant.phone_number }}) (<a href="mailto:{{ participant.email_address }}">{{ participant.email_address }}</a>, {{ participant.phone_number }})
</small> </small>
@@ -412,7 +415,7 @@ Wichtig: das System verschickt keine Bestätigung an dich oder den neuen Teilneh
{% endif %} {% endif %}
</form> </form>
</div> </div>
</h5> </div>
</div> </div>
<div id="collapseParticipant_{{ participant.id }}" <div id="collapseParticipant_{{ participant.id }}"
class="panel-collapse collapse {% if form.errors %}in{% endif %}" 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 /> <hr />
<div class="pull-right text-info" style="margin-right: 1em;" <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' %} {% bootstrap_icon 'question-sign' %}
</div> </div>
@@ -486,12 +489,18 @@ Wichtig: das System verschickt keine Bestätigung an dich oder den neuen Teilneh
{% for registration in registrations_answered %} {% for registration in registrations_answered %}
<div> <div>
<button disabled="disabled" <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> <span class="{% if registration.status.accepted %}text-success{% else %}text-muted{% endif %}">{% bootstrap_icon 'plus-sign' %}</span>
</button> </button>
&nbsp; &nbsp;
<button disabled="disabled" <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> <span class="{% if not registration.status.accepted %}text-danger{% else %}text-muted{% endif %}">{% bootstrap_icon 'minus-sign' %}</span>
</button> </button>
&nbsp; &nbsp;
@@ -509,13 +518,20 @@ Wichtig: das System verschickt keine Bestätigung an dich oder den neuen Teilneh
{% bootstrap_icon 'info-sign' %} {% bootstrap_icon 'info-sign' %}
</span> </span>
</span> </span>
&nbsp;
<span class="text-info" title="Bei dieser Anmeldung hast du bereits {% if has_permission_update_registration %}
am {{ registration.status.updated_at|date:'d. F Y, G:i' }} <div class="pull-right">
auf {% if registration.status.accepted %}Plus{% else %}Minus{% endif %} geklickt. <form action="" method="post" class="form-inline">
"> {% csrf_token %}
{% bootstrap_icon 'question-sign' %} <input type="hidden" name="registration" value="{{ registration.id }}">
</span> <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> </div>
{% endfor %} {% endfor %}
</div> </div>
@@ -541,6 +557,14 @@ auf {% if registration.status.accepted %}Plus{% else %}Minus{% endif %} geklickt
<div class="panel-body"> <div class="panel-body">
{% for participant in participants_trash %} {% for participant in participants_trash %}
<div> <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"> <span class="text-muted">
{{ participant.get_full_name }} {{ participant.get_full_name }}
(<a href="mailto:{{ participant.email_address }}">{{ participant.email_address }}</a>, (<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> </span>
{% endif %} {% endif %}
</span> </span>
&nbsp;
<span class="text-info" title="Diesen Teilnehmer hast du {% if has_permission_update_participants %}
am {{ participant.trashed_at|date:'d. F Y, G:i' }} <div class="pull-right">
von Position {{ participant.position }} der Teilnehmerliste entfernt. <form action="" method="post" class="form-inline">
"> {% csrf_token %}
{% bootstrap_icon 'question-sign' %} <input type="hidden" name="id" value="{{ participant.id }}">
</span> <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> </div>
{% endfor %} {% endfor %}
</div> </div>

View File

@@ -299,6 +299,11 @@ class EventRegistrationsView(EventPermissionMixin, generic.DetailView):
def _reject_registration(self, registration): def _reject_registration(self, registration):
registration.rejected() 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): def _swap_participants_position(self, participant1, participant2):
event = participant1.event event = participant1.event
pos_tmp = event.participants.count() + 1 pos_tmp = event.participants.count() + 1
@@ -347,6 +352,14 @@ class EventRegistrationsView(EventPermissionMixin, generic.DetailView):
self._reject_registration(registration) self._reject_registration(registration)
else: else:
raise FieldDoesNotExist('Event has no registrations') 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': elif action == 'confirm_payment':
self.enforce_permission(event, permission='payment') self.enforce_permission(event, permission='payment')
participant_id = request.POST.get('id') participant_id = request.POST.get('id')
@@ -374,6 +387,18 @@ class EventRegistrationsView(EventPermissionMixin, generic.DetailView):
participant.save() participant.save()
messages.success(request, _(u'Teilnehmer in den Papierkorb verschoben: {}'.format(trashed.get_full_name()))) 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': elif action == 'moveup_participant':
self.enforce_permission(event, permission='update-participants') self.enforce_permission(event, permission='update-participants')
participant_id = request.POST.get('id') participant_id = request.POST.get('id')