this is only in dav_registration for now. dav_events is following.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import datetime
|
||||
import logging
|
||||
from django import forms
|
||||
from django.utils.translation import ugettext, ugettext_lazy as _
|
||||
@@ -25,6 +26,28 @@ class RegistrationForm(forms.ModelForm):
|
||||
'note': forms.Textarea(attrs={'rows': 5}),
|
||||
}
|
||||
|
||||
def clean_year_of_birth(self):
|
||||
now = datetime.datetime.now()
|
||||
year_now = now.year
|
||||
max_age = 100
|
||||
val = self.cleaned_data.get('year_of_birth')
|
||||
if val > year_now:
|
||||
raise forms.ValidationError(
|
||||
ugettext(u'Dein Geburtsjahr liegt in der Zukunft?'
|
||||
u' Das finden wir gut,'
|
||||
u' aber bitte melde dich besser mal per E-Mail bei uns.'),
|
||||
code='to_young',
|
||||
)
|
||||
elif val < (year_now - max_age):
|
||||
raise forms.ValidationError(
|
||||
ugettext(u'Du bist schon über %(max_age)d Jahre alt?'
|
||||
u' Das finden wir gut,'
|
||||
u' aber bitte melde dich besser mal per E-Mail bei uns.'),
|
||||
params={'max_age': max_age},
|
||||
code='to_old',
|
||||
)
|
||||
return val
|
||||
|
||||
def clean_experience(self):
|
||||
val = self.cleaned_data.get('experience')
|
||||
if val == '':
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.29 on 2020-12-09 09:20
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('dav_registration', '0008_auto_20201208_1906'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='registration',
|
||||
name='year_of_birth',
|
||||
field=models.IntegerField(default=1870, 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).', verbose_name='Geburtsjahr'),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
@@ -22,6 +22,7 @@ Personendaten
|
||||
{{ registration.postal_code }} {{ registration.city }}
|
||||
Telefon: {{ registration.phone_number }}
|
||||
E-Mail: {{ registration.email_address }}
|
||||
Jahrgang: {{ registration.year_of_birth }}
|
||||
{% if registration.dav_member %}DAV Mitgliedsnummer: {{ registration.dav_number }}{% else %}DAV Mitglied: Nein{% endif %}
|
||||
|
||||
Notfall-Kontakt
|
||||
|
||||
@@ -19,6 +19,8 @@ Notfall-Kontakt:
|
||||
Erfahrung:
|
||||
{% if registration.experience %}{{ registration.experience }}{% else %}-{% endif %}
|
||||
|
||||
Jahrgang: {{ registration.year_of_birth }} (ungefähres Alter: {{ registration.approx_age }})
|
||||
|
||||
Anmerkung:
|
||||
{% if registration.note %}{{ registration.note }}{% else %}-{% endif %}
|
||||
|
||||
|
||||
@@ -90,12 +90,21 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-3">
|
||||
{% bootstrap_field form.year_of_birth %}
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
{% bootstrap_field form.dav_number %}
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<strong>Nichtmitglieder</strong>
|
||||
{% bootstrap_field form.not_dav_member %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<span class="hidden">Antrag auf reduzierten Teilnehmerbeitrag</span>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
{% bootstrap_field form.emergency_contact %}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user