From cbc3df97c1f52f3fcdfe66b8fb27c2b7c754f3b6 Mon Sep 17 00:00:00 2001 From: heinzel Date: Fri, 18 Dec 2020 11:48:10 +0100 Subject: [PATCH] Reduced participant fee: added toggle buttons within office views and improved html --- .../dav_event_office/event_detail.html | 57 +++++++++++++------ .../dav_event_office/participant_list.html | 23 ++++++-- dav_event_office/views.py | 5 ++ .../dav_events/event_registrations.html | 43 ++++++++------ dav_events/views/events.py | 16 ++++++ 5 files changed, 104 insertions(+), 40 deletions(-) diff --git a/dav_event_office/templates/dav_event_office/event_detail.html b/dav_event_office/templates/dav_event_office/event_detail.html index 3ab06c4..fa4c9e2 100644 --- a/dav_event_office/templates/dav_event_office/event_detail.html +++ b/dav_event_office/templates/dav_event_office/event_detail.html @@ -210,6 +210,17 @@
{% csrf_token %} + {% if event.charge and has_permission_payment %} + +   + {% endif %} {% if has_permission_update_participants %} {% elif event.charge and participant.paid %}   - - {% if participant.apply_reduced_fee %}%{% else %} {% endif %}{% bootstrap_icon 'piggy-bank' %} - + %{% bootstrap_icon 'piggy-bank' %} {% elif event.charge and has_permission_payment %}   - {% if participant.apply_reduced_fee %}%{% elif participant.created_at|date:'U' < '1608764400' %}? {% else %} {% endif %} {% elif event.charge %}   - - {% if participant.apply_reduced_fee %}%{% elif participant.created_at|date:'U' < '1608764400' %}? {% else %} {% endif %}{% bootstrap_icon 'piggy-bank' %} - + {% if participant.apply_reduced_fee %}%{% else %}? {% endif %}{% bootstrap_icon 'piggy-bank' %} {% else %} - + {% endif %}
@@ -287,6 +303,11 @@ {% endif %} +
+
+ {% trans 'Gebuchte Teilnahmegebühren' %}: {{ earnings|floatformat:2 }} € +
+
{% if participant_emails %}
@@ -380,14 +401,16 @@ {% if event.charge and participant.paid %}   - - {% if participant.apply_reduced_fee %}%{% else %} {% endif %}{% bootstrap_icon 'piggy-bank' %} - + %{% bootstrap_icon 'piggy-bank' %} {% elif event.charge %}   - - {% if participant.apply_reduced_fee %}%{% else %} {% endif %}{% bootstrap_icon 'piggy-bank' %} - + %{% bootstrap_icon 'piggy-bank' %} {% endif %}
diff --git a/dav_event_office/templates/dav_event_office/participant_list.html b/dav_event_office/templates/dav_event_office/participant_list.html index 99c2439..c9a9e71 100644 --- a/dav_event_office/templates/dav_event_office/participant_list.html +++ b/dav_event_office/templates/dav_event_office/participant_list.html @@ -71,24 +71,37 @@
{% csrf_token %} + {% if event.charge %} + +   + {% endif %} {% if event.charge and participant.paid %} - {% if participant.apply_reduced_fee %}%{% else %} {% endif %}   ({{ event.charge|floatformat:'-2' }}{% if participant.apply_reduced_fee %} / 2{% endif %} €) {% elif event.charge %} - {% if participant.apply_reduced_fee %}%{% elif participant.created_at|date:'U' < '1608764400' %}? {% else %} {% endif %}   ({{ event.charge|floatformat:'-2' }}{% if participant.apply_reduced_fee %} / 2{% endif %} €) {% else %} - - {% bootstrap_icon 'piggy-bank' %} - + {% endif %}
diff --git a/dav_event_office/views.py b/dav_event_office/views.py index c44a136..148d3b1 100644 --- a/dav_event_office/views.py +++ b/dav_event_office/views.py @@ -53,6 +53,11 @@ class ParticipantListView(generic.ListView): participant = get_object_or_404(Participant, pk=participant_id) participant.paid = False participant.save() + elif action == 'toggle_reduced_fee': + participant_id = request.POST.get('id') + participant = get_object_or_404(Participant, pk=participant_id) + participant.apply_reduced_fee = not participant.apply_reduced_fee + participant.save() else: messages.error(request, 'unsupported action: {}'.format(action)) return HttpResponseRedirect(reverse('dav_event_office:participant-list')) diff --git a/dav_events/templates/dav_events/event_registrations.html b/dav_events/templates/dav_events/event_registrations.html index b565db3..531557e 100644 --- a/dav_events/templates/dav_events/event_registrations.html +++ b/dav_events/templates/dav_events/event_registrations.html @@ -305,7 +305,7 @@ Das musst du selbst (per E-Mail oder telefonisch) machen. {% if registration.apply_reduced_fee %}   - %{% bootstrap_icon 'piggy-bank' %} (reduzierte Gebühr) + %{% bootstrap_icon 'piggy-bank' %} (reduzierte Gebühr) {% endif %} @@ -399,30 +399,35 @@ Wichtig: das System verschickt keine Bestätigung an dich oder den neuen Teilneh {% endif %} {% if event.charge and participant.paid and has_permission_payment %}   - {% if participant.apply_reduced_fee %}%{% else %} {% endif %} {% elif event.charge and participant.paid %}   - - {% if participant.apply_reduced_fee %}%{% else %} {% endif %}{% bootstrap_icon 'piggy-bank' %} - + %{% bootstrap_icon 'piggy-bank' %} {% elif event.charge and has_permission_payment %}   - {% if participant.apply_reduced_fee %}%{% else %} {% endif %} {% elif event.charge %}   - - {% if participant.apply_reduced_fee %}%{% else %} {% endif %}{% bootstrap_icon 'piggy-bank' %} - + %{% bootstrap_icon 'piggy-bank' %} {% else %} - + {% endif %}
@@ -587,14 +592,16 @@ von Position {{ participant.position }} der Teilnehmerliste entfernt. {% if event.charge and participant.paid %}   - - {% if participant.apply_reduced_fee %}%{% else %} {% endif %}{% bootstrap_icon 'piggy-bank' %} - + %{% bootstrap_icon 'piggy-bank' %} {% elif event.charge %}   - - {% if participant.apply_reduced_fee %}%{% else %} {% endif %}{% bootstrap_icon 'piggy-bank' %} - + %{% bootstrap_icon 'piggy-bank' %} {% endif %} diff --git a/dav_events/views/events.py b/dav_events/views/events.py index febf662..e98196e 100644 --- a/dav_events/views/events.py +++ b/dav_events/views/events.py @@ -219,6 +219,16 @@ class EventRegistrationsView(EventPermissionMixin, generic.DetailView): participants_trash = event.trashed_participants.all() context['participants_trash'] = participants_trash + earnings = 0 + if event.charge: + for participant in participants: + if participant.paid: + if participant.apply_reduced_fee: + earnings += event.charge / 2 + else: + earnings += event.charge + context['earnings'] = earnings + if participants.count() > 1: email_list = [u'"{}" <{}>'.format(p.get_full_name(), p.email_address) for p in participants] email_list.sort() @@ -344,6 +354,12 @@ class EventRegistrationsView(EventPermissionMixin, generic.DetailView): self._reset_registration(registration) else: raise FieldDoesNotExist('Event has no registrations') + elif action == 'toggle_reduced_fee': + self.enforce_permission(event, permission='payment') + participant_id = request.POST.get('id') + participant = event.participants.get(id=participant_id) + participant.apply_reduced_fee = not participant.apply_reduced_fee + participant.save() elif action == 'confirm_payment': self.enforce_permission(event, permission='payment') participant_id = request.POST.get('id')