support for reduced fee #31

Merged
heinzel merged 6 commits from heinzel into master 2020-12-09 18:13:30 +01:00
4 changed files with 28 additions and 3 deletions
Showing only changes of commit c3bbaa7200 - Show all commits

View File

@@ -1,5 +1,8 @@
from django.utils import timezone
from ..models import Registration from ..models import Registration
THIS_YEAR = timezone.now().year
class RegistrationMixin(object): class RegistrationMixin(object):
def create_registration(self, data): def create_registration(self, data):

View File

@@ -10,7 +10,7 @@ from django.utils.translation import get_language
from dav_base.tests.generic import EmailTestMixin from dav_base.tests.generic import EmailTestMixin
from dav_events.tests.generic import EventMixin from dav_events.tests.generic import EventMixin
from .generic import RegistrationMixin from .generic import THIS_YEAR, RegistrationMixin
MAIL_SELF_TEMPLATE = """Hallo {participant_full_name}, MAIL_SELF_TEMPLATE = """Hallo {participant_full_name},
@@ -36,6 +36,7 @@ Here
1 Karlsruhe 1 Karlsruhe
Telefon: 12 Telefon: 12
E-Mail: {participant_email} E-Mail: {participant_email}
Jahrgang: {year_of_birth}
DAV Mitgliedsnummer: 0 DAV Mitgliedsnummer: 0
Notfall-Kontakt Notfall-Kontakt
@@ -77,6 +78,8 @@ Notfall-Kontakt:
Erfahrung: Erfahrung:
- -
Jahrgang: {year_of_birth} (ungefähres Alter: {approx_age})
Anmerkung: Anmerkung:
- -
@@ -112,6 +115,7 @@ class EmailsTestCase(EmailTestMixin, EventMixin, RegistrationMixin, TestCase):
'city': 'Karlsruhe', 'city': 'Karlsruhe',
'phone_number': '12', 'phone_number': '12',
'email_address': 'participant@localhost', 'email_address': 'participant@localhost',
'year_of_birth': THIS_YEAR - 10,
'dav_number': '0', 'dav_number': '0',
} }
registration = self.create_registration(registration_data) registration = self.create_registration(registration_data)
@@ -131,6 +135,7 @@ class EmailsTestCase(EmailTestMixin, EventMixin, RegistrationMixin, TestCase):
body = MAIL_SELF_TEMPLATE.format( body = MAIL_SELF_TEMPLATE.format(
participant_full_name=registration.get_full_name(), participant_full_name=registration.get_full_name(),
participant_email=registration.email_address, participant_email=registration.email_address,
year_of_birth=registration.year_of_birth,
event_number=event.get_number(), event_number=event.get_number(),
event_title=event.title, event_title=event.title,
event_formated_date=event.get_formated_date(), event_formated_date=event.get_formated_date(),
@@ -157,6 +162,7 @@ class EmailsTestCase(EmailTestMixin, EventMixin, RegistrationMixin, TestCase):
'phone_number': '+49 721 1234567890 AB (Büro)', 'phone_number': '+49 721 1234567890 AB (Büro)',
'dav_member': False, 'dav_member': False,
'dav_number': '131/00/007*12345', 'dav_number': '131/00/007*12345',
'year_of_birth': 1976,
'emergency_contact': 'Call 911!', 'emergency_contact': 'Call 911!',
'experience': 'Yes, we can!', 'experience': 'Yes, we can!',
'note': 'Automatischer Software Test\nGruß\n heinzel =u}', 'note': 'Automatischer Software Test\nGruß\n heinzel =u}',
@@ -173,6 +179,7 @@ class EmailsTestCase(EmailTestMixin, EventMixin, RegistrationMixin, TestCase):
search += '{} {}\n'.format(registration_data['postal_code'], registration_data['city']) search += '{} {}\n'.format(registration_data['postal_code'], registration_data['city'])
search += 'Telefon: {}\n'.format(registration_data['phone_number']) search += 'Telefon: {}\n'.format(registration_data['phone_number'])
search += 'E-Mail: {}\n'.format(registration_data['email_address']) search += 'E-Mail: {}\n'.format(registration_data['email_address'])
search += 'Jahrgang: {}\n'.format(registration_data['year_of_birth'])
search += 'DAV Mitglied: Nein\n' search += 'DAV Mitglied: Nein\n'
self.assertIn(search, mail.body) self.assertIn(search, mail.body)
@@ -215,6 +222,7 @@ class EmailsTestCase(EmailTestMixin, EventMixin, RegistrationMixin, TestCase):
'city': 'Karlsruhe', 'city': 'Karlsruhe',
'phone_number': '12', 'phone_number': '12',
'email_address': 'participant@localhost', 'email_address': 'participant@localhost',
'year_of_birth': THIS_YEAR - 86,
'dav_number': '0', 'dav_number': '0',
} }
registration = self.create_registration(registration_data) registration = self.create_registration(registration_data)
@@ -235,6 +243,8 @@ class EmailsTestCase(EmailTestMixin, EventMixin, RegistrationMixin, TestCase):
body = MAIL_TRAINER_TEMPLATE.format( body = MAIL_TRAINER_TEMPLATE.format(
participant_full_name=registration.get_full_name(), participant_full_name=registration.get_full_name(),
participant_email=registration.email_address, participant_email=registration.email_address,
year_of_birth=registration.year_of_birth,
approx_age=registration.approx_age(),
event_number=event.get_number(), event_number=event.get_number(),
event_title=event.title, event_title=event.title,
event_formated_date=event.get_formated_date(), event_formated_date=event.get_formated_date(),
@@ -260,6 +270,7 @@ class EmailsTestCase(EmailTestMixin, EventMixin, RegistrationMixin, TestCase):
'phone_number': '+49 721 1234567890 AB (Büro)', 'phone_number': '+49 721 1234567890 AB (Büro)',
'dav_member': False, 'dav_member': False,
'dav_number': '131/00/007*12345', 'dav_number': '131/00/007*12345',
'year_of_birth': THIS_YEAR,
'emergency_contact': 'Call 911!', 'emergency_contact': 'Call 911!',
'experience': 'Yes, we can!', 'experience': 'Yes, we can!',
'note': 'Automatischer Software Test\nGruß\n heinzel =u}', 'note': 'Automatischer Software Test\nGruß\n heinzel =u}',
@@ -293,6 +304,12 @@ class EmailsTestCase(EmailTestMixin, EventMixin, RegistrationMixin, TestCase):
search += '\n' search += '\n'
self.assertIn(search, mail.body) self.assertIn(search, mail.body)
search = '\n'
search += 'Jahrgang: '
search += str(registration_data['year_of_birth'])
search += ' (ungefähres Alter: 0)\n'
self.assertIn(search, mail.body)
search = '\n' search = '\n'
search += 'Anmerkung:\n' search += 'Anmerkung:\n'
search += registration_data['note'] search += registration_data['note']

View File

@@ -6,7 +6,7 @@ from django.test import TestCase
from dav_events.tests.generic import EventMixin from dav_events.tests.generic import EventMixin
from .generic import RegistrationMixin from .generic import THIS_YEAR, RegistrationMixin
class RegistrationTestCase(EventMixin, RegistrationMixin, TestCase): class RegistrationTestCase(EventMixin, RegistrationMixin, TestCase):
@@ -32,6 +32,7 @@ class RegistrationTestCase(EventMixin, RegistrationMixin, TestCase):
'city': 'Karlsruhe', 'city': 'Karlsruhe',
'phone_number': '12', 'phone_number': '12',
'email_address': 'participant@localhost', 'email_address': 'participant@localhost',
'year_of_birth': THIS_YEAR,
} }
dav_numbers = ['0', '12345', '131/00/12345'] dav_numbers = ['0', '12345', '131/00/12345']
for n in dav_numbers: for n in dav_numbers:
@@ -50,6 +51,7 @@ class RegistrationTestCase(EventMixin, RegistrationMixin, TestCase):
'city': 'Karlsruhe', 'city': 'Karlsruhe',
'phone_number': '12', 'phone_number': '12',
'email_address': 'participant@localhost', 'email_address': 'participant@localhost',
'year_of_birth': THIS_YEAR,
} }
with self.assertRaisesMessage(ValidationError, with self.assertRaisesMessage(ValidationError,
'Wenn du DAV Mitglied bist, brauchen wir deine Mitgliedsnummer.'): 'Wenn du DAV Mitglied bist, brauchen wir deine Mitgliedsnummer.'):
@@ -71,6 +73,7 @@ class RegistrationTestCase(EventMixin, RegistrationMixin, TestCase):
'city': 'Karlsruhe', 'city': 'Karlsruhe',
'phone_number': '12', 'phone_number': '12',
'email_address': 'participant@localhost', 'email_address': 'participant@localhost',
'year_of_birth': THIS_YEAR,
} }
dav_numbers = ['Nein', '-', '13100123456789'] dav_numbers = ['Nein', '-', '13100123456789']
for n in dav_numbers: for n in dav_numbers:
@@ -93,6 +96,7 @@ class RegistrationTestCase(EventMixin, RegistrationMixin, TestCase):
'city': 'Karlsruhe', 'city': 'Karlsruhe',
'phone_number': '12', 'phone_number': '12',
'email_address': 'participant@localhost', 'email_address': 'participant@localhost',
'year_of_birth': THIS_YEAR,
'dav_member': False, 'dav_member': False,
} }
self.create_registration(registration_data) self.create_registration(registration_data)

View File

@@ -9,7 +9,7 @@ from dav_events.tests.generic import EventMixin
from ..models import Registration from ..models import Registration
from ..utils import purge_registrations from ..utils import purge_registrations
from .generic import RegistrationMixin from .generic import THIS_YEAR, RegistrationMixin
class UtilsTestCase(RegistrationMixin, EventMixin, TestCase): class UtilsTestCase(RegistrationMixin, EventMixin, TestCase):
@@ -37,6 +37,7 @@ class UtilsTestCase(RegistrationMixin, EventMixin, TestCase):
'city': 'Karlsruhe', 'city': 'Karlsruhe',
'phone_number': '555 5555', 'phone_number': '555 5555',
'email_address': 'participant@localhost', 'email_address': 'participant@localhost',
'year_of_birth': THIS_YEAR - 44,
'dav_number': '1', 'dav_number': '1',
} }