participants: added support for year of birth
All checks were successful
buildbot/tox Build done.

This commit is contained in:
2020-12-09 13:45:25 +01:00
parent c3bbaa7200
commit 3f3bb2512b
4 changed files with 42 additions and 2 deletions

View File

@@ -28,6 +28,7 @@ class AbstractParticipant(models.Model):
email_address = models.EmailField(verbose_name=_('E-Mail-Adresse'))
phone_number = models.CharField(max_length=254,
verbose_name=_('Telefonnummer'))
year_of_birth = models.IntegerField(verbose_name=_('Geburtsjahr'))
dav_member = models.BooleanField(default=True,
verbose_name=_('DAV Mitglied'),
help_text=_('In Ausnahmefällen nehmen wir auch Nichtmitglieder mit.'))
@@ -48,6 +49,11 @@ class AbstractParticipant(models.Model):
purge_at = models.DateTimeField()
def approx_age(self):
now = datetime.datetime.now()
year_now = now.year
return year_now - self.year_of_birth
class Meta:
abstract = True
@@ -62,6 +68,7 @@ class AbstractParticipant(models.Model):
{address}, {postal_code} {city}
DAV Mitglied: {dav_info}
Jahrgang: {year_of_birth} (ungefähres Alter: {approx_age})
Notfallkontakt:
{emergency_contact}
@@ -80,6 +87,8 @@ class AbstractParticipant(models.Model):
postal_code=self.postal_code,
city=self.city,
dav_info=dav_info,
year_of_birth=self.year_of_birth,
approx_age=self.approx_age(),
emergency_contact=self.emergency_contact,
note=self.note,
)