Fix #9 Registrations: Add support for non members
All checks were successful
buildbot/tox Build done.
All checks were successful
buildbot/tox Build done.
This commit is contained in:
26
dav_events/migrations/0034_auto_20201015_1738.py
Normal file
26
dav_events/migrations/0034_auto_20201015_1738.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.29 on 2020-10-15 15:38
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.core.validators
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('dav_events', '0033_auto_20200925_1543'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='participant',
|
||||
name='dav_member',
|
||||
field=models.BooleanField(default=True, help_text='In Ausnahmefällen nehmen wir auch Nichtmitglieder mit.', verbose_name='DAV Mitglied'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='participant',
|
||||
name='dav_number',
|
||||
field=models.CharField(blank=True, max_length=62, validators=[django.core.validators.RegexValidator('^([0-9]{1,10}/[0-9]{2,10}/)?[0-9]{1,10}(\\*[0-9]{1,10})?(\\*[0-9]{4}\\*[0-9]{4})?([* ][0-9]{8})?$', 'Ungültiges Format.')], verbose_name='DAV Mitgliedsnummer'),
|
||||
),
|
||||
]
|
||||
@@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
import datetime
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.db import models
|
||||
from django.utils import timezone
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
@@ -32,8 +33,11 @@ class Participant(models.Model):
|
||||
email_address = models.EmailField(verbose_name=_('E-Mail-Adresse'))
|
||||
phone_number = models.CharField(max_length=254,
|
||||
verbose_name=_('Telefonnummer'))
|
||||
dav_member = models.BooleanField(default=True,
|
||||
verbose_name=_('DAV Mitglied'),
|
||||
help_text=_('In Ausnahmefällen nehmen wir auch Nichtmitglieder mit.'))
|
||||
dav_number = models.CharField(max_length=62,
|
||||
validators=[DAVNumberValidator],
|
||||
blank=True, validators=[DAVNumberValidator],
|
||||
verbose_name=_('DAV Mitgliedsnummer'))
|
||||
emergency_contact = models.TextField(blank=True,
|
||||
verbose_name=_('Notfall-Kontakt'),
|
||||
@@ -69,25 +73,38 @@ class Participant(models.Model):
|
||||
text = """{fullname}
|
||||
{address}, {postal_code} {city}
|
||||
|
||||
DAV Mitglied: {dav_info}
|
||||
|
||||
Notfallkontakt:
|
||||
{emergency_contact}
|
||||
|
||||
Anmerkung:
|
||||
{note}
|
||||
"""
|
||||
if not self.dav_member:
|
||||
dav_info = _('Nein')
|
||||
else:
|
||||
dav_info = self.dav_number
|
||||
|
||||
return text.format(
|
||||
fullname=self.get_full_name(),
|
||||
address=self.address,
|
||||
postal_code=self.postal_code,
|
||||
city=self.city,
|
||||
dav_info=dav_info,
|
||||
emergency_contact=self.emergency_contact,
|
||||
note=self.note,
|
||||
)
|
||||
|
||||
def clean(self):
|
||||
if self.dav_member and not self.dav_number:
|
||||
raise ValidationError({'dav_number': _('Bei DAV Mitgliedern brauchen wir die Mitgliedsnummer.')})
|
||||
|
||||
def save(self, **kwargs):
|
||||
if not self.purge_at and self.event:
|
||||
self.purge_at = self.__class__.calc_purge_at(self.event)
|
||||
|
||||
self.full_clean()
|
||||
super(Participant, self).save(**kwargs)
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -29,9 +29,12 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<div class="col-sm-3">
|
||||
{% bootstrap_field form.dav_number %}
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
{% bootstrap_field form.dav_member %}
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
{% bootstrap_field form.emergency_contact %}
|
||||
</div>
|
||||
|
||||
@@ -230,9 +230,9 @@ class EventRegistrationsView(EventPermissionMixin, generic.DetailView):
|
||||
registrations_support = hasattr(event, 'registrations')
|
||||
context['registrations_support'] = registrations_support
|
||||
if registrations_support:
|
||||
registrations_unanswered = event.registrations.filter(answered=False)
|
||||
registrations_all = event.registrations.all()
|
||||
context['registrations_unanswered'] = registrations_unanswered
|
||||
registrations_pending = registrations_all.filter(answered=False)
|
||||
context['registrations_pending'] = registrations_pending
|
||||
context['registrations_all'] = registrations_all
|
||||
context['registrations'] = registrations_all
|
||||
|
||||
|
||||
Reference in New Issue
Block a user