registration: add support for year of birth
Some checks failed
buildbot/tox Build done.

this is only in dav_registration for now. dav_events is following.
This commit is contained in:
2020-12-09 10:51:06 +01:00
parent 998b4cd5cf
commit 0ff559d548
6 changed files with 70 additions and 0 deletions

View File

@@ -40,6 +40,12 @@ class Registration(models.Model):
phone_number = models.CharField(max_length=254,
verbose_name=_('Telefonnummer'),
help_text=_('Idealerweise eine Mobilfunk-Nummer'))
year_of_birth = models.IntegerField(verbose_name=_('Geburtsjahr'),
help_text=_('Manchmal müssen wir wissen, wie alt unsere Teilnehmer sind.'
' Darum brauchen wir die vierstellige Jahreszahl,'
' des Jahres in dem du geboren bist (zb. 1991).'))
dav_member = models.BooleanField(default=True,
verbose_name=_('DAV Mitglied'))
dav_number = models.CharField(max_length=62,
@@ -74,6 +80,11 @@ class Registration(models.Model):
answered_obsolete = models.BooleanField(default=False, verbose_name=_('Durch Tourleitung beantwortet'))
def approx_age(self):
now = datetime.datetime.now()
year_now = now.year
return year_now - self.year_of_birth
@staticmethod
def pk2hexstr(pk):
return hex(pk * 113)[2:] # 113 has no meaning, but it produce nice looking hex codes.
@@ -113,6 +124,7 @@ class Registration(models.Model):
{address}, {postal_code} {city}
DAV Mitglied: {dav_info}
Jahrgang: {year_of_birth} (ungefähres Alter: {approx_age})
Erfahrung:
{experience}
@@ -131,6 +143,8 @@ Anmerkung:
postal_code=self.postal_code,
city=self.city,
dav_info=dav_info,
year_of_birth=self.year_of_birth,
approx_age=self.approx_age(),
experience=self.experience,
note=self.note,
)