From 1210d8f5349bdfcce5e3d6b1818cd2e346f74ab4 Mon Sep 17 00:00:00 2001 From: Jens Kleineheismann Date: Mon, 26 Feb 2018 17:57:07 +0100 Subject: [PATCH] Added field registration_required. --- TODO.txt | 2 - dav_events/forms/events.py | 8 +++- .../0016_event_registration_required.py | 20 ++++++++ dav_events/models.py | 40 ++++++++-------- .../dav_events/emails/event_to_publish.txt | 6 +-- dav_events/templates/dav_events/event.html | 8 ++-- dav_events/templates/dav_events/event.txt | 6 +-- .../event_create/RegistrationForm.html | 46 +++++++++++-------- 8 files changed, 85 insertions(+), 51 deletions(-) create mode 100644 dav_events/migrations/0016_event_registration_required.py diff --git a/TODO.txt b/TODO.txt index 049634f..9342b91 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,4 +1,3 @@ -- teilnehmerzahl (im template): check if min == max - Anzeige Bahnfahrt - ApproachForm aufteilen - Save as Draft @@ -12,7 +11,6 @@ - vorbereitung: textfeld beschreibung einleitung, so dass beschreibung nur auf webseite geht. - kontaktdaten für 2. und 3. trainer wieder weg - erster teil des anmeldungshowto editierbar -- feld 'anmeldung nicht nötig' - publizierendes feld für redaktionellen hinweis - vortreffen ohne datum? diff --git a/dav_events/forms/events.py b/dav_events/forms/events.py index ceee8bb..628113a 100644 --- a/dav_events/forms/events.py +++ b/dav_events/forms/events.py @@ -617,6 +617,10 @@ class RegistrationForm(EventCreateForm): max_participants = forms.IntegerField(min_value=0, label=_(u'Max. Teilnehmer')) + registration_required = forms.BooleanField(required=False, + label=_(u'Anmeldung notwendig'), + ) + deadline = forms.ChoiceField(choices=choices.DEADLINE_CHOICES, label=_(u'Anmeldeschluss'), widget=forms.RadioSelect()) @@ -827,8 +831,8 @@ class SummaryForm(EventCreateForm): widget=forms.Textarea(attrs={'rows': 5})) def _proceed_session_data(self, session_data): - max_participants = self._session_data.get('max_participants', 0) - if max_participants: + registration_required = self._session_data.get('registration_required', False) + if registration_required: deadline = self._session_data.get('deadline', None) if deadline == 'OTHER': deadline = self._session_data.get('deadline_other', None) diff --git a/dav_events/migrations/0016_event_registration_required.py b/dav_events/migrations/0016_event_registration_required.py new file mode 100644 index 0000000..89229f4 --- /dev/null +++ b/dav_events/migrations/0016_event_registration_required.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.9 on 2018-02-26 16:55 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('dav_events', '0015_auto_20180226_1253'), + ] + + operations = [ + migrations.AddField( + model_name='event', + name='registration_required', + field=models.BooleanField(default=False), + ), + ] diff --git a/dav_events/models.py b/dav_events/models.py index ba1aa2a..8efeab9 100644 --- a/dav_events/models.py +++ b/dav_events/models.py @@ -131,13 +131,6 @@ class Event(models.Model): pre_meeting_2 = models.DateTimeField(blank=True, null=True) - # RegistrationForm - min_participants = models.IntegerField(default=0) - max_participants = models.IntegerField(default=0) - deadline = models.DateField(blank=True, - null=True) - registration_howto = models.TextField(blank=True) - # TrainerForm trainer_firstname = models.CharField(max_length=config.TRAINER_NAME_MAX_LENGTH, blank=True) @@ -157,6 +150,14 @@ class Event(models.Model): trainer_3_phone = models.CharField(max_length=config.PHONE_NUMBER_MAX_LENGTH, blank=True) + # RegistrationForm + min_participants = models.IntegerField(default=0) + max_participants = models.IntegerField(default=0) + registration_required = models.BooleanField(default=False) + deadline = models.DateField(blank=True, + null=True) + registration_howto = models.TextField(blank=True) + # ChargesForm charge = models.FloatField(default=0) additional_costs = models.CharField(max_length=config.ADDITIONAL_COSTS_MAX_LENGTH, @@ -381,9 +382,10 @@ class Event(models.Model): 'event': self, 'status': self.get_status(), 'number': self.get_number(), + 'title': self.title, + 'description': self.description, 'mode': self.mode, 'sport': self.sport, - 'title': self.title, 'first_day': self.first_day, 'last_day': self.last_day, 'normalized_date': self.get_formated_date(format='normalized'), @@ -394,7 +396,6 @@ class Event(models.Model): 'alt_normalized_date': self.get_alt_formated_date(format='normalized'), 'alt_normalized_long_date': self.get_alt_formated_date(format='normalized_long'), 'alt_normalized_short_date': self.get_alt_formated_date(format='normalized_short'), - 'description': self.description, 'course_topic_1': self.course_topic_1, 'course_topic_2': self.course_topic_2, 'course_topic_3': self.course_topic_3, @@ -409,25 +410,20 @@ class Event(models.Model): 'course_goal_6': self.course_goal_6, 'country': self.country, 'location': self.location, - 'basecamp': self.basecamp, - 'accommodation': self.accommodation, - 'accommodation_other': self.accommodation_other, - 'meals': self.meals, - 'meals_other': self.meals_other, 'transport': self.transport, 'transport_other': self.transport_other, 'meeting_time': self.meeting_time, 'meeting_point': self.meeting_point, 'meeting_point_other': self.meeting_point_other, + 'basecamp': self.basecamp, + 'accommodation': self.accommodation, + 'accommodation_other': self.accommodation_other, + 'meals': self.meals, + 'meals_other': self.meals_other, 'requirements': self.requirements, 'equipment': self.equipment, 'pre_meeting_1': self.pre_meeting_1, 'pre_meeting_2': self.pre_meeting_2, - 'deadline': self.deadline, - 'min_participants': self.min_participants, - 'max_participants': self.max_participants, - 'charge': self.charge, - 'additional_costs': self.additional_costs, 'trainer_firstname': self.trainer_firstname, 'trainer_familyname': self.trainer_familyname, 'trainer_email': self.trainer_email, @@ -438,7 +434,13 @@ class Event(models.Model): 'trainer_3_fullname': self.trainer_3_fullname, 'trainer_3_email': self.trainer_3_email, 'trainer_3_phone': self.trainer_3_phone, + 'min_participants': self.min_participants, + 'max_participants': self.max_participants, + 'registration_required': self.registration_required, + 'deadline': self.deadline, 'registration_howto': self.registration_howto, + 'charge': self.charge, + 'additional_costs': self.additional_costs, 'planned_publication_date': self.planned_publication_date, 'internal_note': self.internal_note, } diff --git a/dav_events/templates/dav_events/emails/event_to_publish.txt b/dav_events/templates/dav_events/emails/event_to_publish.txt index 61a3b7c..341ebf4 100644 --- a/dav_events/templates/dav_events/emails/event_to_publish.txt +++ b/dav_events/templates/dav_events/emails/event_to_publish.txt @@ -53,11 +53,11 @@ Veröffentlichung: {% if planned_publication_date %}{{ planned_publication_date| {% endif %}{% if pre_meeting_1 %}{% if pre_meeting_2 %}{% trans 'Vortreffen' %} 1: {{ pre_meeting_1|date:'l, d. F Y, G:i'|cut:':00' }} {% trans 'Uhr' %}, DAV {% trans 'Sektionszentrum' %}
{% trans 'Vortreffen' %} 2: {{ pre_meeting_2|date:'l, d. F Y, G:i'|cut:':00' }} {% trans 'Uhr' %}, DAV {% trans 'Sektionszentrum' %}
{% else %}{% trans 'Vortreffen' %}: {{ pre_meeting_1|date:'l, d. F Y, G:i'|cut:':00' }} {% trans 'Uhr' %}, DAV {% trans 'Sektionszentrum' %}
{% endif %} -{% endif %}{% if min_participants > 0 or max_participants > 0 %}{% trans 'Teilnehmerzahl' %}: {% if min_participants > 0 and max_participants > 0 %}{{ min_participants }} - {{ max_participants }} {% trans 'Teilnehmer' %}{% elif min_participants > 0 %}min. {{ min_participants }} {% trans 'Teilnehmer' %}{% else %}max. {{ max_participants }} {% trans 'Teilnehmer' %}{% endif %}
+{% endif %}{% if min_participants > 0 or max_participants > 0 %}{% trans 'Teilnehmerzahl' %}: {% if min_participants == max_participants %}{{ max_participants }} {% trans 'Teilnehmer' %}{% elif min_participants > 0 and max_participants > 0 %}{{ min_participants }} - {{ max_participants }} {% trans 'Teilnehmer' %}{% elif min_participants > 0 %}min. {{ min_participants }} {% trans 'Teilnehmer' %}{% else %}max. {{ max_participants }} {% trans 'Teilnehmer' %}{% endif %}
{% endif %}{% if charge > 0 or additional_costs %}{% trans 'Kosten' %}: {% if charge > 0 %}{{ charge|floatformat:'-2' }} € {% trans 'Teilnahmegebühr' %}{% endif %}{% if additional_costs %}{% if charge > 0 %} {% trans 'zzgl.' %} {% endif %}{{ additional_costs }}{% endif %}
-{% endif %}{% if deadline %}{% trans 'Anmeldeschluss' %}: {{ deadline|date:'l, d. F Y' }}
+{% endif %}{% if registration_required and deadline %}{% trans 'Anmeldeschluss' %}: {{ deadline|date:'l, d. F Y' }}
{% endif %}{% if trainer_2_fullname %}{% if mode == 'training' %}{% trans 'Ausbildungsteam' %}:{% else %}{% trans 'Team' %}:{% endif %} {{ trainer_firstname }} {{ trainer_familyname }}{% if trainer_email or trainer_phone %} ({% if trainer_email %}{{ trainer_email }}{% endif %}{% if trainer_email and trainer_phone %}, {% endif %}{% if trainer_phone %}{{ trainer_phone }}{% endif %}){% endif %}, {{ trainer_2_fullname }}{% if trainer_2_email or trainer_2_phone %} ({% if trainer_2_email %}{{ trainer_2_email }}{% endif %}{% if trainer_2_email and trainer_2_phone %}, {% endif %}{% if trainer_2_phone %}{{ trainer_2_phone }}{% endif %}){% endif %}{% if trainer_3_fullname %}, {{ trainer_3_fullname }}{% if trainer_3_email or trainer_3_phone %} ({% if trainer_3_email %}{{ trainer_3_email }}{% endif %}{% if trainer_3_email and trainer_3_phone %}, {% endif %}{% if trainer_3_phone %}{{ trainer_3_phone }}{% endif %}){% endif %}{% endif %}
{% endif %}{% if trainer_familyname %}{% trans 'Leitung' %}: {{ trainer_firstname }} {{ trainer_familyname }}{% if trainer_email or trainer_phone %} ({% if trainer_email %}{{ trainer_email }}{% endif %}{% if trainer_email and trainer_phone %}, {% endif %}{% if trainer_phone %} {{ trainer_phone }}{% endif %}){% endif %} -{% endif %}{% if registration_howto %} +{% endif %}{% if registration_required and registration_howto %}

{{ registration_howto }}

{% endif %} diff --git a/dav_events/templates/dav_events/event.html b/dav_events/templates/dav_events/event.html index ed7967d..3602a39 100644 --- a/dav_events/templates/dav_events/event.html +++ b/dav_events/templates/dav_events/event.html @@ -133,7 +133,9 @@ {% endif %} {% if min_participants > 0 or max_participants > 0 %} {% trans 'Teilnehmerzahl' %}: - {% if min_participants > 0 and max_participants > 0 %} + {% if min_participants == max_participants %} + {{ max_participants }} {% trans 'Teilnehmer' %} + {% elif min_participants > 0 and max_participants > 0 %} {{ min_participants }} - {{ max_participants }} {% trans 'Teilnehmer' %} {% elif min_participants > 0 %} min. {{ min_participants }} {% trans 'Teilnehmer' %} @@ -153,7 +155,7 @@ {% endif %}
{% endif %} - {% if deadline %}{% trans 'Anmeldeschluss' %}: {{ deadline|date:'l, d. F Y' }}
{% endif %} + {% if registration_required and deadline %}{% trans 'Anmeldeschluss' %}: {{ deadline|date:'l, d. F Y' }}
{% endif %} {% if trainer_2_fullname %} {% if mode == 'training' %} {% trans 'Ausbildungsteam' %}: @@ -176,7 +178,7 @@ {% endif %} {% endif %} - {% if registration_howto %} + {% if registration_required and registration_howto %} diff --git a/dav_events/templates/dav_events/event.txt b/dav_events/templates/dav_events/event.txt index fb04381..c345229 100644 --- a/dav_events/templates/dav_events/event.txt +++ b/dav_events/templates/dav_events/event.txt @@ -38,11 +38,11 @@ {% endif %}{% if meeting_point and meeting_point != 'NONE' %}{% trans 'Treffpunkt' %}: {% if meeting_time %}{{ meeting_time|time:'G:i'|cut:':00' }} Uhr, {% endif %}{% if meeting_point == 'OTHER' %}{{ meeting_point_other }}{% else %}{{ event.get_meeting_point_display }}{% endif %} {% endif %}{% if pre_meeting_1 %}{% if pre_meeting_2 %}{% trans 'Vortreffen' %} 1: {{ pre_meeting_1|date:'l, d. F Y, G:i'|cut:':00' }} {% trans 'Uhr' %}, DAV {% trans 'Sektionszentrum' %} {% trans 'Vortreffen' %} 2: {{ pre_meeting_2|date:'l, d. F Y, G:i'|cut:':00' }} {% trans 'Uhr' %}, DAV {% trans 'Sektionszentrum' %}{% else %}{% trans 'Vortreffen' %}: {{ pre_meeting_1|date:'l, d. F Y, G:i'|cut:':00' }} {% trans 'Uhr' %}, DAV {% trans 'Sektionszentrum' %}{% endif %} -{% endif %}{% if min_participants > 0 or max_participants > 0 %}{% trans 'Teilnehmerzahl' %}: {% if min_participants > 0 and max_participants > 0 %}{{ min_participants }} - {{ max_participants }} {% trans 'Teilnehmer' %}{% elif min_participants > 0 %}min. {{ min_participants }} {% trans 'Teilnehmer' %}{% else %}max. {{ max_participants }} {% trans 'Teilnehmer' %}{% endif %} +{% endif %}{% if min_participants > 0 or max_participants > 0 %}{% trans 'Teilnehmerzahl' %}: {% if min_participants == max_participants %}{{ max_participants }} {% trans 'Teilnehmer' %}{% elif min_participants > 0 and max_participants > 0 %}{{ min_participants }} - {{ max_participants }} {% trans 'Teilnehmer' %}{% elif min_participants > 0 %}min. {{ min_participants }} {% trans 'Teilnehmer' %}{% else %}max. {{ max_participants }} {% trans 'Teilnehmer' %}{% endif %} {% endif %}{% if charge > 0 or additional_costs %}{% trans 'Kosten' %}: {% if charge > 0 %}{{ charge|floatformat:'-2' }} € {% trans 'Teilnahmegebühr' %}{% endif %}{% if additional_costs %}{% if charge > 0 %} {% trans 'zzgl.' %} {% endif %}{{ additional_costs }}{% endif %} -{% endif %}{% if deadline %}{% trans 'Anmeldeschluss' %}: {{ deadline|date:'l, d. F Y' }} +{% endif %}{% if registration_required and deadline %}{% trans 'Anmeldeschluss' %}: {{ deadline|date:'l, d. F Y' }} {% endif %}{% if trainer_2_fullname %}{% if mode == 'training' %}{% trans 'Ausbildungsteam' %}:{% else %}{% trans 'Team' %}:{% endif %} {{ trainer_firstname }} {{ trainer_familyname }}{% if trainer_email or trainer_phone %} ({% if trainer_email %}{{ trainer_email }}{% endif %}{% if trainer_email and trainer_phone %}, {% endif %}{% if trainer_phone %}{{ trainer_phone }}{% endif %}){% endif %}, {{ trainer_2_fullname }}{% if trainer_2_email or trainer_2_phone %} ({% if trainer_2_email %}{{ trainer_2_email }}{% endif %}{% if trainer_2_email and trainer_2_phone %}, {% endif %}{% if trainer_2_phone %}{{ trainer_2_phone }}{% endif %}){% endif %}{% if trainer_3_fullname %}, {{ trainer_3_fullname }}{% if trainer_3_email or trainer_3_phone %} ({% if trainer_3_email %}{{ trainer_3_email }}{% endif %}{% if trainer_3_email and trainer_3_phone %}, {% endif %}{% if trainer_3_phone %}{{ trainer_3_phone }}{% endif %}){% endif %}{% endif %} {% endif %}{% if trainer_familyname %}{% trans 'Leitung' %}: {{ trainer_firstname }} {{ trainer_familyname }}{% if trainer_email or trainer_phone %} ({% if trainer_email %}{{ trainer_email }}{% endif %}{% if trainer_email and trainer_phone %}, {% endif %}{% if trainer_phone %}{{ trainer_phone }}{% endif %}){% endif %} -{% endif %}{% if registration_howto %} +{% endif %}{% if registration_required and registration_howto %} {{ registration_howto }} {% endif %} \ No newline at end of file diff --git a/dav_events/templates/dav_events/event_create/RegistrationForm.html b/dav_events/templates/dav_events/event_create/RegistrationForm.html index 12d9318..d646b19 100644 --- a/dav_events/templates/dav_events/event_create/RegistrationForm.html +++ b/dav_events/templates/dav_events/event_create/RegistrationForm.html @@ -4,35 +4,39 @@ {% block head-additional %} {% endblock head-additional %} @@ -52,7 +56,11 @@
-
+
+ + {% bootstrap_field form.registration_required %} +
+
{% bootstrap_field form.deadline %}