This commit is contained in:
@@ -1 +1 @@
|
||||
default_app_config = 'dav_registration.apps.AppConfig'
|
||||
default_app_config = 'dav_registration.apps.AppConfig' # pylint: disable=invalid-name
|
||||
|
||||
@@ -9,7 +9,7 @@ DEFAULT_SETTINGS = (
|
||||
|
||||
class AppConfig(_AppConfig):
|
||||
name = 'dav_registration'
|
||||
verbose_name = u'DAV Kurs-Anmeldungen'
|
||||
verbose_name = 'DAV Kurs-Anmeldungen'
|
||||
default_settings = DEFAULT_SETTINGS
|
||||
|
||||
def ready(self):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
from dav_base.emails import AbstractMail
|
||||
|
||||
|
||||
class AbstractRegistrationMail(AbstractMail):
|
||||
class AbstractRegistrationMail(AbstractMail): # pylint: disable=too-few-public-methods
|
||||
def __init__(self, recipient, registration):
|
||||
self._recipient = recipient
|
||||
self._registration = registration
|
||||
@@ -13,45 +13,45 @@ class AbstractRegistrationMail(AbstractMail):
|
||||
subject_fmt = self._subject
|
||||
|
||||
if self._event.number:
|
||||
subject_fmt = u'%s: %s' % (self._event.number, subject_fmt)
|
||||
subject_fmt = '%s: %s' % (self._event.number, subject_fmt)
|
||||
|
||||
return super(AbstractRegistrationMail, self)._get_subject(subject_fmt=subject_fmt, **kwargs)
|
||||
return super()._get_subject(subject_fmt=subject_fmt, **kwargs)
|
||||
|
||||
def _get_recipients(self):
|
||||
if hasattr(self._recipient, 'get_full_name') and hasattr(self._recipient, 'email'):
|
||||
r = u'"{fullname}" <{email}>'.format(fullname=self._recipient.get_full_name(),
|
||||
email=self._recipient.email)
|
||||
r = '"{fullname}" <{email}>'.format(fullname=self._recipient.get_full_name(),
|
||||
email=self._recipient.email)
|
||||
else:
|
||||
r = self._recipient
|
||||
return [r]
|
||||
|
||||
def _get_context_data(self, extra_context=None):
|
||||
context = super(AbstractRegistrationMail, self)._get_context_data(extra_context=extra_context)
|
||||
context = super()._get_context_data(extra_context=extra_context)
|
||||
context['recipient'] = self._recipient
|
||||
context['registration'] = self._registration
|
||||
context['event'] = self._event
|
||||
return context
|
||||
|
||||
|
||||
class InformTrainerRegistrationMail(AbstractRegistrationMail):
|
||||
_subject = u'Anmeldung {full_name}'
|
||||
class InformTrainerRegistrationMail(AbstractRegistrationMail): # pylint: disable=too-few-public-methods
|
||||
_subject = 'Anmeldung {full_name}'
|
||||
_template_name = 'dav_registration/emails/inform_trainer.txt'
|
||||
|
||||
def _get_subject(self, subject_fmt=None, **kwargs):
|
||||
kwargs['full_name'] = self._registration.get_full_name()
|
||||
return super(InformTrainerRegistrationMail, self)._get_subject(subject_fmt=subject_fmt, **kwargs)
|
||||
return super()._get_subject(subject_fmt=subject_fmt, **kwargs)
|
||||
|
||||
def _get_reply_to(self):
|
||||
s = u'"{fullname}" <{email}>'.format(fullname=self._registration.get_full_name(),
|
||||
email=self._registration.email_address)
|
||||
return [s]
|
||||
reply_to = '"{fullname}" <{email}>'.format(fullname=self._registration.get_full_name(),
|
||||
email=self._registration.email_address)
|
||||
return [reply_to]
|
||||
|
||||
|
||||
class InformSelfRegistrationMail(AbstractRegistrationMail):
|
||||
_subject = u'Deine Anmeldung'
|
||||
class InformSelfRegistrationMail(AbstractRegistrationMail): # pylint: disable=too-few-public-methods
|
||||
_subject = 'Deine Anmeldung'
|
||||
_template_name = 'dav_registration/emails/inform_self.txt'
|
||||
|
||||
def _get_reply_to(self):
|
||||
s = u'"{fullname}" <{email}>'.format(fullname=self._event.owner.get_full_name(),
|
||||
email=self._event.owner.email)
|
||||
return [s]
|
||||
reply_to = '"{fullname}" <{email}>'.format(fullname=self._event.owner.get_full_name(),
|
||||
email=self._event.owner.email)
|
||||
return [reply_to]
|
||||
|
||||
@@ -11,13 +11,13 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
class RegistrationForm(forms.ModelForm):
|
||||
not_dav_member = forms.BooleanField(required=False,
|
||||
label=_(u'Ich bin noch kein DAV Mitglied.'),
|
||||
help_text=u'%s<br />\n%s' % (
|
||||
_(u'Wenn du noch kein DAV Mitglied bist,'
|
||||
u' oder deine Aufnahme noch in Arbeit ist,'
|
||||
u' kreuze dieses Feld hier an.'),
|
||||
_(u'Spätestens zu Veranstaltungsbeginn muss'
|
||||
u' jedoch eine Mitgliedschaft bestehen.')
|
||||
label=_('Ich bin noch kein DAV Mitglied.'),
|
||||
help_text='%s<br />\n%s' % (
|
||||
_('Wenn du noch kein DAV Mitglied bist,'
|
||||
' oder deine Aufnahme noch in Arbeit ist,'
|
||||
' kreuze dieses Feld hier an.'),
|
||||
_('Spätestens zu Veranstaltungsbeginn muss'
|
||||
' jedoch eine Mitgliedschaft bestehen.')
|
||||
))
|
||||
|
||||
class Meta:
|
||||
@@ -30,7 +30,7 @@ class RegistrationForm(forms.ModelForm):
|
||||
'note': forms.Textarea(attrs={'rows': 5}),
|
||||
}
|
||||
labels = {
|
||||
'apply_reduced_fee': _(u'Ich bin noch keine 25 Jahre alt oder besitze einen "Karlsruher Pass".'),
|
||||
'apply_reduced_fee': _('Ich bin noch keine 25 Jahre alt oder besitze einen "Karlsruher Pass".'),
|
||||
}
|
||||
|
||||
def clean_year_of_birth(self):
|
||||
@@ -40,16 +40,16 @@ class RegistrationForm(forms.ModelForm):
|
||||
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.'),
|
||||
ugettext('Dein Geburtsjahr liegt in der Zukunft?'
|
||||
' Das finden wir gut,'
|
||||
' 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.'),
|
||||
ugettext('Du bist schon über %(max_age)d Jahre alt?'
|
||||
' Das finden wir gut,'
|
||||
' aber bitte melde dich besser mal per E-Mail bei uns.'),
|
||||
params={'max_age': max_age},
|
||||
code='to_old',
|
||||
)
|
||||
@@ -63,8 +63,8 @@ class RegistrationForm(forms.ModelForm):
|
||||
need_experience = False
|
||||
if need_experience:
|
||||
raise forms.ValidationError(
|
||||
ugettext(u'Die Tourenleiter*innen brauchen ein paar Angaben,'
|
||||
u' was du bereits kannst oder wie fit du bist.'),
|
||||
ugettext('Die Tourenleiter*innen brauchen ein paar Angaben,'
|
||||
' was du bereits kannst oder wie fit du bist.'),
|
||||
code='need_experience',
|
||||
)
|
||||
return val
|
||||
@@ -73,18 +73,18 @@ class RegistrationForm(forms.ModelForm):
|
||||
val = self.cleaned_data.get('privacy_policy_accepted')
|
||||
if not val and self.instance.privacy_policy:
|
||||
raise forms.ValidationError(
|
||||
ugettext(u'Wir müssen deine Daten leider speichern können,'
|
||||
u' damit wir wissen, dass du teilnehmen möchtest.'),
|
||||
ugettext('Wir müssen deine Daten leider speichern können,'
|
||||
' damit wir wissen, dass du teilnehmen möchtest.'),
|
||||
code='privacy_policy_not_accepted',
|
||||
)
|
||||
return val
|
||||
|
||||
def clean(self):
|
||||
super(RegistrationForm, self).clean()
|
||||
super().clean()
|
||||
dav_member = self.cleaned_data.get('dav_member')
|
||||
dav_number = self.cleaned_data.get('dav_number')
|
||||
if dav_member and not dav_number:
|
||||
error_msg = ugettext(u'Wenn du DAV Mitglied bist, brauchen wir deine Mitgliedsnummer.')
|
||||
error_msg = ugettext('Wenn du DAV Mitglied bist, brauchen wir deine Mitgliedsnummer.')
|
||||
self.add_error('not_dav_member', error_msg)
|
||||
raise forms.ValidationError(error_msg, code='dav_number_missing')
|
||||
return self.cleaned_data
|
||||
|
||||
@@ -182,7 +182,7 @@ Anmerkung:
|
||||
self.purge_at = self.__class__.calc_purge_at(self.event)
|
||||
|
||||
self.full_clean()
|
||||
super(Registration, self).save(**kwargs)
|
||||
super().save(**kwargs)
|
||||
|
||||
if creating:
|
||||
status = RegistrationStatus(registration=self)
|
||||
@@ -238,7 +238,7 @@ class RegistrationStatus(models.Model):
|
||||
|
||||
def save(self, **kwargs):
|
||||
self.full_clean()
|
||||
super(RegistrationStatus, self).save(**kwargs)
|
||||
super().save(**kwargs)
|
||||
|
||||
def set_accepted(self):
|
||||
self.accepted = True
|
||||
|
||||
@@ -5,7 +5,7 @@ from . import emails
|
||||
registration_created = Signal(providing_args=['registration'])
|
||||
|
||||
|
||||
def send_emails_on_registration(sender, **kwargs):
|
||||
def send_emails_on_registration(sender, **kwargs): # pylint: disable=unused-argument
|
||||
registration = kwargs.get('registration')
|
||||
|
||||
# Inform the event owner (trainer)
|
||||
@@ -14,7 +14,7 @@ def send_emails_on_registration(sender, **kwargs):
|
||||
email.send()
|
||||
|
||||
# Inform the potential participant
|
||||
recipient = u'"{fullname}" <{email}>'.format(fullname=registration.get_full_name(),
|
||||
email=registration.email_address)
|
||||
recipient = '"{fullname}" <{email}>'.format(fullname=registration.get_full_name(),
|
||||
email=registration.email_address)
|
||||
email = emails.InformSelfRegistrationMail(recipient=recipient, registration=registration)
|
||||
email.send()
|
||||
|
||||
@@ -12,5 +12,3 @@ def render_event_paragraphs(event):
|
||||
@register.simple_tag
|
||||
def render_event_facts(event):
|
||||
return render_to_string('dav_registration/event/facts.html', {'event': event})
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ from ..models import Registration
|
||||
THIS_YEAR = timezone.now().year
|
||||
|
||||
|
||||
class RegistrationMixin(object):
|
||||
class RegistrationMixin: # pylint: disable=too-few-public-methods
|
||||
def create_registration(self, data):
|
||||
r = Registration(**data)
|
||||
r.save()
|
||||
|
||||
@@ -95,7 +95,7 @@ Zeitpunkt der Datenlöschung: {purge_at}
|
||||
|
||||
class EmailsTestCase(EmailTestMixin, EventMixin, RegistrationMixin, TestCase):
|
||||
def setUp(self):
|
||||
super(EmailsTestCase, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
app_config = apps.get_app_config('dav_events')
|
||||
app_config.settings.enable_email_on_status_update = False
|
||||
|
||||
@@ -11,7 +11,7 @@ from .generic import THIS_YEAR, RegistrationMixin
|
||||
|
||||
class RegistrationTestCase(EventMixin, RegistrationMixin, TestCase):
|
||||
def setUp(self):
|
||||
super(RegistrationTestCase, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
app_config = apps.get_app_config('dav_events')
|
||||
app_config.settings.enable_email_on_status_update = False
|
||||
@@ -100,4 +100,3 @@ class RegistrationTestCase(EventMixin, RegistrationMixin, TestCase):
|
||||
'dav_member': False,
|
||||
}
|
||||
self.create_registration(registration_data)
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ class UtilsTestCase(RegistrationMixin, EventMixin, TestCase):
|
||||
self.submit_event(event)
|
||||
self.accept_event(event)
|
||||
|
||||
for i in range(0, registrations_per_event):
|
||||
for _ in range(0, registrations_per_event):
|
||||
d = registration_data
|
||||
d['event'] = event
|
||||
self.create_registration(d)
|
||||
|
||||
@@ -23,7 +23,7 @@ class RootView(generic.RedirectView):
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
purge_registrations()
|
||||
return super(RootView, self).get(request, *args, **kwargs)
|
||||
return super().get(request, *args, **kwargs)
|
||||
|
||||
|
||||
class EventListView(generic.ListView):
|
||||
@@ -33,14 +33,14 @@ class EventListView(generic.ListView):
|
||||
def get_queryset(self):
|
||||
today = datetime.date.today()
|
||||
|
||||
filter = Q(flags__status__code__in=('publishing', 'publishing_web', 'publishing_facebook',
|
||||
'published', 'published_web', 'published_facebook'))
|
||||
filter &= Q(planned_publication_date__isnull=True) | Q(planned_publication_date__lte=today)
|
||||
filter &= Q(first_day__gte=today)
|
||||
# filter &= Q(registration_closed=False)
|
||||
# filter &= Q(deadline__isnull=True) | Q(deadline__gte=today)
|
||||
filter_exp = Q(flags__status__code__in=('publishing', 'publishing_web', 'publishing_facebook',
|
||||
'published', 'published_web', 'published_facebook'))
|
||||
filter_exp &= Q(planned_publication_date__isnull=True) | Q(planned_publication_date__lte=today)
|
||||
filter_exp &= Q(first_day__gte=today)
|
||||
# filter_exp &= Q(registration_closed=False)
|
||||
# filter_exp &= Q(deadline__isnull=True) | Q(deadline__gte=today)
|
||||
|
||||
qs = self.model.objects.filter(filter).order_by('first_day', 'number').distinct()
|
||||
qs = self.model.objects.filter(filter_exp).order_by('first_day', 'number').distinct()
|
||||
|
||||
return qs
|
||||
|
||||
@@ -52,14 +52,14 @@ class EventDetailView(generic.DetailView):
|
||||
def get_queryset(self):
|
||||
today = datetime.date.today()
|
||||
|
||||
filter = Q(flags__status__code__in=('publishing', 'publishing_web', 'publishing_facebook',
|
||||
'published', 'published_web', 'published_facebook'))
|
||||
filter &= Q(planned_publication_date__isnull=True) | Q(planned_publication_date__lte=today)
|
||||
filter &= Q(first_day__gte=today)
|
||||
# filter &= Q(registration_closed=False)
|
||||
# filter &= Q(deadline__isnull=True) | Q(deadline__gte=today)
|
||||
filter_exp = Q(flags__status__code__in=('publishing', 'publishing_web', 'publishing_facebook',
|
||||
'published', 'published_web', 'published_facebook'))
|
||||
filter_exp &= Q(planned_publication_date__isnull=True) | Q(planned_publication_date__lte=today)
|
||||
filter_exp &= Q(first_day__gte=today)
|
||||
# filter_exp &= Q(registration_closed=False)
|
||||
# filter_exp &= Q(deadline__isnull=True) | Q(deadline__gte=today)
|
||||
|
||||
qs = self.model.objects.filter(filter).distinct()
|
||||
qs = self.model.objects.filter(filter_exp).distinct()
|
||||
|
||||
return qs
|
||||
|
||||
@@ -74,72 +74,72 @@ class RegistrationView(generic.CreateView):
|
||||
def get_queryset(self):
|
||||
today = datetime.date.today()
|
||||
|
||||
filter = Q(flags__status__code__in=('publishing', 'publishing_web', 'publishing_facebook',
|
||||
'published', 'published_web', 'published_facebook'))
|
||||
filter &= Q(planned_publication_date__isnull=True) | Q(planned_publication_date__lte=today)
|
||||
filter &= Q(first_day__gte=today)
|
||||
filter &= Q(registration_closed=False)
|
||||
filter &= Q(deadline__isnull=True) | Q(deadline__gte=today)
|
||||
filter_exp = Q(flags__status__code__in=('publishing', 'publishing_web', 'publishing_facebook',
|
||||
'published', 'published_web', 'published_facebook'))
|
||||
filter_exp &= Q(planned_publication_date__isnull=True) | Q(planned_publication_date__lte=today)
|
||||
filter_exp &= Q(first_day__gte=today)
|
||||
filter_exp &= Q(registration_closed=False)
|
||||
filter_exp &= Q(deadline__isnull=True) | Q(deadline__gte=today)
|
||||
|
||||
qs = Event.objects.filter(filter).distinct()
|
||||
qs = Event.objects.filter(filter_exp).distinct()
|
||||
|
||||
return qs
|
||||
|
||||
def get_initial(self):
|
||||
initials = super(RegistrationView, self).get_initial()
|
||||
initials = super().get_initial()
|
||||
return initials
|
||||
|
||||
def get_form(self, form_class=None):
|
||||
form = super(RegistrationView, self).get_form(form_class)
|
||||
form = super().get_form(form_class)
|
||||
|
||||
event = self.get_object()
|
||||
|
||||
experience_label = form.fields['experience'].label
|
||||
experience_help_text = form.fields['experience'].help_text
|
||||
if event.sport == 'B':
|
||||
experience_label = _(u'Eigene Bergerfahrung')
|
||||
experience_label = _('Eigene Bergerfahrung')
|
||||
elif event.sport == 'K' and event.terrain == 'alpine':
|
||||
experience_label = _(u'Eigene Fels- und Bergerfahrung')
|
||||
experience_label = _('Eigene Fels- und Bergerfahrung')
|
||||
if event.level == 'beginner':
|
||||
experience_help_text = u'%s<br /> %s<br /> %s' % (
|
||||
_(u'Warst du schon mal im Gebirge klettern?'),
|
||||
_(u'In welchem Schwierigkeitsgrad hast du Spaß?'),
|
||||
_(u'Bist du schon mal vorgestiegen?')
|
||||
experience_help_text = '%s<br /> %s<br /> %s' % (
|
||||
_('Warst du schon mal im Gebirge klettern?'),
|
||||
_('In welchem Schwierigkeitsgrad hast du Spaß?'),
|
||||
_('Bist du schon mal vorgestiegen?')
|
||||
)
|
||||
else:
|
||||
experience_help_text = u'%s<br /> %s<br /> %s' % (
|
||||
_(u'In welchen Klettergebieten/Touren warst du bisher unterwegs?'),
|
||||
_(u'In welchem Schwierigkeitsgrad hast du im Vorstieg Spaß?'),
|
||||
_(u'Wie waren die Touren abgesichert, in denen du dich noch wohlgefühlt hast?')
|
||||
experience_help_text = '%s<br /> %s<br /> %s' % (
|
||||
_('In welchen Klettergebieten/Touren warst du bisher unterwegs?'),
|
||||
_('In welchem Schwierigkeitsgrad hast du im Vorstieg Spaß?'),
|
||||
_('Wie waren die Touren abgesichert, in denen du dich noch wohlgefühlt hast?')
|
||||
)
|
||||
elif event.sport == 'K':
|
||||
experience_label = _(u'Eigene Klettererfahrung')
|
||||
experience_label = _('Eigene Klettererfahrung')
|
||||
if event.level == 'beginner':
|
||||
experience_help_text = u'%s<br /> %s<br /> %s' % (
|
||||
_(u'Warst du schon mal am Fels klettern?'),
|
||||
_(u'In welchem Schwierigkeitsgrad hast du Spaß?'),
|
||||
_(u'Bist du schon mal vorgestiegen?')
|
||||
experience_help_text = '%s<br /> %s<br /> %s' % (
|
||||
_('Warst du schon mal am Fels klettern?'),
|
||||
_('In welchem Schwierigkeitsgrad hast du Spaß?'),
|
||||
_('Bist du schon mal vorgestiegen?')
|
||||
)
|
||||
else:
|
||||
experience_help_text = u'%s<br /> %s<br /> %s' % (
|
||||
_(u'In welchen Klettergebieten warst du bisher unterwegs?'),
|
||||
_(u'In welchem Schwierigkeitsgrad hast du im Vorstieg Spaß?'),
|
||||
_(u'Wie waren die Touren abgesichert, in denen du dich noch wohlgefühlt hast?')
|
||||
experience_help_text = '%s<br /> %s<br /> %s' % (
|
||||
_('In welchen Klettergebieten warst du bisher unterwegs?'),
|
||||
_('In welchem Schwierigkeitsgrad hast du im Vorstieg Spaß?'),
|
||||
_('Wie waren die Touren abgesichert, in denen du dich noch wohlgefühlt hast?')
|
||||
)
|
||||
elif event.sport == 'M':
|
||||
experience_label = _(u'Eigene MTB-Erfahrung')
|
||||
experience_help_text = u'%s' % (
|
||||
_(u'Was für Touren bist du schon gefahren?')
|
||||
experience_label = _('Eigene MTB-Erfahrung')
|
||||
experience_help_text = '%s' % (
|
||||
_('Was für Touren bist du schon gefahren?')
|
||||
)
|
||||
if event.level != 'beginner':
|
||||
experience_help_text += u'<br /> %s' % (
|
||||
_(u'Single-Trail-Schwierigkeit (S0-S5) bei der du dich wohl fühlst?')
|
||||
experience_help_text += '<br /> %s' % (
|
||||
_('Single-Trail-Schwierigkeit (S0-S5) bei der du dich wohl fühlst?')
|
||||
)
|
||||
elif event.sport == 'S':
|
||||
experience_label = _(u'Eigene Skitouren- und Bergerfahrung')
|
||||
experience_label = _('Eigene Skitouren- und Bergerfahrung')
|
||||
elif event.sport == 'W':
|
||||
experience_help_text += u'<br /> %s' % (
|
||||
_(u'Kann frei gelassen werden.')
|
||||
experience_help_text += '<br /> %s' % (
|
||||
_('Kann frei gelassen werden.')
|
||||
)
|
||||
|
||||
form.fields['experience'].label = experience_label
|
||||
@@ -150,7 +150,7 @@ class RegistrationView(generic.CreateView):
|
||||
return form
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(RegistrationView, self).get_context_data(**kwargs)
|
||||
context = super().get_context_data(**kwargs)
|
||||
event = self.get_object()
|
||||
context['event'] = event
|
||||
context['privacy_policy'] = app_config.settings.privacy_policy
|
||||
@@ -158,16 +158,16 @@ class RegistrationView(generic.CreateView):
|
||||
return context
|
||||
|
||||
def form_valid(self, form):
|
||||
r = super(RegistrationView, self).form_valid(form)
|
||||
r = super().form_valid(form)
|
||||
self.request.session['registration_id'] = form.instance.pk
|
||||
message = _(u'Deine Anmeldung wurde erfolgreich gespeichert.')
|
||||
message = _('Deine Anmeldung wurde erfolgreich gespeichert.')
|
||||
messages.success(self.request, message)
|
||||
return r
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
if 'registration_id' in request.session:
|
||||
del request.session['registration_id']
|
||||
return super(RegistrationView, self).post(request, *args, **kwargs)
|
||||
return super().post(request, *args, **kwargs)
|
||||
|
||||
|
||||
class RegistrationSuccessView(generic.DetailView):
|
||||
|
||||
Reference in New Issue
Block a user