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:
@@ -32,11 +32,11 @@ Vorgang: {registration_hexstr} (wird nur gebraucht, wenn irgendwas schief geht)
|
||||
Personendaten
|
||||
-------------
|
||||
{participant_full_name}
|
||||
|
||||
|
||||
Telefon:
|
||||
Here
|
||||
1 Karlsruhe
|
||||
Telefon: 12
|
||||
E-Mail: {participant_email}
|
||||
DAV Mitgliedsnummer:
|
||||
DAV Mitgliedsnummer: 0
|
||||
|
||||
Notfall-Kontakt
|
||||
---------------
|
||||
@@ -66,10 +66,10 @@ Vorgang: {registration_hexstr}
|
||||
|
||||
Teilnehmer*in:
|
||||
{participant_full_name}
|
||||
,
|
||||
|
||||
Here, 1 Karlsruhe
|
||||
12
|
||||
{participant_email}
|
||||
|
||||
0
|
||||
|
||||
Notfall-Kontakt:
|
||||
-
|
||||
@@ -107,7 +107,12 @@ class EmailsTestCase(EmailTestMixin, EventMixin, RegistrationMixin, TestCase):
|
||||
'event': event,
|
||||
'personal_names': 'Participant',
|
||||
'family_names': 'One',
|
||||
'address': 'Here',
|
||||
'postal_code': '1',
|
||||
'city': 'Karlsruhe',
|
||||
'phone_number': '12',
|
||||
'email_address': 'participant@localhost',
|
||||
'dav_number': '0',
|
||||
}
|
||||
registration = self.create_registration(registration_data)
|
||||
|
||||
@@ -150,6 +155,7 @@ class EmailsTestCase(EmailTestMixin, EventMixin, RegistrationMixin, TestCase):
|
||||
'postal_code': '76131',
|
||||
'city': 'Karlsruhe',
|
||||
'phone_number': '+49 721 1234567890 AB (Büro)',
|
||||
'dav_member': False,
|
||||
'dav_number': '131/00/007*12345',
|
||||
'emergency_contact': 'Call 911!',
|
||||
'experience': 'Yes, we can!',
|
||||
@@ -167,7 +173,7 @@ class EmailsTestCase(EmailTestMixin, EventMixin, RegistrationMixin, TestCase):
|
||||
search += '{} {}\n'.format(registration_data['postal_code'], registration_data['city'])
|
||||
search += 'Telefon: {}\n'.format(registration_data['phone_number'])
|
||||
search += 'E-Mail: {}\n'.format(registration_data['email_address'])
|
||||
search += 'DAV Mitgliedsnummer: {}\n'.format(registration_data['dav_number'])
|
||||
search += 'DAV Mitglied: Nein\n'
|
||||
self.assertIn(search, mail.body)
|
||||
|
||||
search = '\n'
|
||||
@@ -204,7 +210,12 @@ class EmailsTestCase(EmailTestMixin, EventMixin, RegistrationMixin, TestCase):
|
||||
'event': event,
|
||||
'personal_names': 'Participant',
|
||||
'family_names': 'One',
|
||||
'address': 'Here',
|
||||
'postal_code': '1',
|
||||
'city': 'Karlsruhe',
|
||||
'phone_number': '12',
|
||||
'email_address': 'participant@localhost',
|
||||
'dav_number': '0',
|
||||
}
|
||||
registration = self.create_registration(registration_data)
|
||||
|
||||
@@ -247,6 +258,7 @@ class EmailsTestCase(EmailTestMixin, EventMixin, RegistrationMixin, TestCase):
|
||||
'postal_code': '76131',
|
||||
'city': 'Karlsruhe',
|
||||
'phone_number': '+49 721 1234567890 AB (Büro)',
|
||||
'dav_member': False,
|
||||
'dav_number': '131/00/007*12345',
|
||||
'emergency_contact': 'Call 911!',
|
||||
'experience': 'Yes, we can!',
|
||||
@@ -265,7 +277,7 @@ class EmailsTestCase(EmailTestMixin, EventMixin, RegistrationMixin, TestCase):
|
||||
search += '\n'
|
||||
search += registration_data['email_address']
|
||||
search += '\n'
|
||||
search += registration_data['dav_number']
|
||||
search += 'Nicht DAV Mitglied'
|
||||
search += '\n'
|
||||
self.assertIn(search, mail.body)
|
||||
|
||||
|
||||
99
dav_registration/tests/test_models.py
Normal file
99
dav_registration/tests/test_models.py
Normal file
@@ -0,0 +1,99 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
from django.apps import apps
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.test import TestCase
|
||||
|
||||
from dav_events.tests.generic import EventMixin
|
||||
|
||||
from .generic import RegistrationMixin
|
||||
|
||||
|
||||
class RegistrationTestCase(EventMixin, RegistrationMixin, TestCase):
|
||||
def setUp(self):
|
||||
super(RegistrationTestCase, self).setUp()
|
||||
|
||||
app_config = apps.get_app_config('dav_events')
|
||||
app_config.settings.enable_email_on_status_update = False
|
||||
|
||||
self.event = self.create_event_by_model()
|
||||
self.submit_event(self.event)
|
||||
self.accept_event(self.event)
|
||||
self.confirm_publication_event(self.event)
|
||||
|
||||
def test_create_members(self):
|
||||
event = self.event
|
||||
registration_data = {
|
||||
'event': event,
|
||||
'personal_names': 'Participant',
|
||||
'family_names': 'One',
|
||||
'address': 'Here',
|
||||
'postal_code': '1',
|
||||
'city': 'Karlsruhe',
|
||||
'phone_number': '12',
|
||||
'email_address': 'participant@localhost',
|
||||
}
|
||||
dav_numbers = ['0', '12345', '131/00/12345']
|
||||
for n in dav_numbers:
|
||||
d = registration_data
|
||||
d['dav_number'] = n
|
||||
self.create_registration(d)
|
||||
|
||||
def test_create_members_without_number(self):
|
||||
event = self.event
|
||||
registration_data = {
|
||||
'event': event,
|
||||
'personal_names': 'Participant',
|
||||
'family_names': 'One',
|
||||
'address': 'Here',
|
||||
'postal_code': '1',
|
||||
'city': 'Karlsruhe',
|
||||
'phone_number': '12',
|
||||
'email_address': 'participant@localhost',
|
||||
}
|
||||
with self.assertRaisesMessage(ValidationError,
|
||||
'Wenn du DAV Mitglied bist, brauchen wir deine Mitgliedsnummer.'):
|
||||
self.create_registration(registration_data)
|
||||
|
||||
registration_data['dav_number'] = ''
|
||||
with self.assertRaisesMessage(ValidationError,
|
||||
'Wenn du DAV Mitglied bist, brauchen wir deine Mitgliedsnummer.'):
|
||||
self.create_registration(registration_data)
|
||||
|
||||
def test_create_members_with_invalid_numbers(self):
|
||||
event = self.event
|
||||
registration_data = {
|
||||
'event': event,
|
||||
'personal_names': 'Participant',
|
||||
'family_names': 'One',
|
||||
'address': 'Here',
|
||||
'postal_code': '1',
|
||||
'city': 'Karlsruhe',
|
||||
'phone_number': '12',
|
||||
'email_address': 'participant@localhost',
|
||||
}
|
||||
dav_numbers = ['Nein', '-', '13100123456789']
|
||||
for n in dav_numbers:
|
||||
d = registration_data
|
||||
d['dav_number'] = n
|
||||
|
||||
with self.assertRaises(ValidationError) as context:
|
||||
self.create_registration(d)
|
||||
|
||||
self.assertEqual(context.exception.messages, ['Ungültiges Format.'])
|
||||
|
||||
def test_create_non_member(self):
|
||||
event = self.event
|
||||
registration_data = {
|
||||
'event': event,
|
||||
'personal_names': 'Participant',
|
||||
'family_names': 'One',
|
||||
'address': 'Here',
|
||||
'postal_code': '1',
|
||||
'city': 'Karlsruhe',
|
||||
'phone_number': '12',
|
||||
'email_address': 'participant@localhost',
|
||||
'dav_member': False,
|
||||
}
|
||||
self.create_registration(registration_data)
|
||||
|
||||
@@ -29,6 +29,16 @@ class UtilsTestCase(RegistrationMixin, EventMixin, TestCase):
|
||||
'trainer_familyname': 'One',
|
||||
'trainer_email': 'trainer@localhost',
|
||||
}
|
||||
registration_data = {
|
||||
'personal_names': 'Participant',
|
||||
'family_names': 'P.',
|
||||
'address': 'Am Fächerbad 2',
|
||||
'postal_code': '76131',
|
||||
'city': 'Karlsruhe',
|
||||
'phone_number': '555 5555',
|
||||
'email_address': 'participant@localhost',
|
||||
'dav_number': '1',
|
||||
}
|
||||
|
||||
first_day = today - (one_day * 367)
|
||||
while first_day < today:
|
||||
@@ -41,7 +51,9 @@ class UtilsTestCase(RegistrationMixin, EventMixin, TestCase):
|
||||
self.accept_event(event)
|
||||
|
||||
for i in range(0, registrations_per_event):
|
||||
self.create_registration({'event': event})
|
||||
d = registration_data
|
||||
d['event'] = event
|
||||
self.create_registration(d)
|
||||
|
||||
purge_registrations()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user