Improved ChargeForm and TrainerForm.

This commit is contained in:
2018-01-20 16:17:45 +01:00
parent 8bb1733427
commit 346249f623
3 changed files with 46 additions and 19 deletions

View File

@@ -34,7 +34,7 @@ class ChoiceSet(object):
class CountryChoiceSet(Countries):
first = ['DE', 'AU', 'CH', 'FR', 'IT']
first = ['DE', 'AUT', 'CH', 'FR', 'IT']
first_repeat = True
first_break = '--'
@@ -96,6 +96,7 @@ SPORT_CHOICES = ChoiceSet([
TERRAIN_CHOICES = ChoiceSet([
('gym', _(u'Kletterhalle')),
('crag', _(u'Klettergarten')),
('flats', _(u'Flachland')),
('submountains', _(u'Mittelgebirge')),
('alpine', _(u'Alpin')),
])

View File

@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from django.utils.translation import ugettext_lazy as _
# Auth Config
@@ -25,84 +26,84 @@ MEALS_OTHER_MAX_LENGTH = COMMON_CHAR_FIELD_LENGTH
ADDITIONAL_COSTS_MAX_LENGTH = COMMON_CHAR_FIELD_LENGTH
FEE_MATRIX = {
'0': {'description': _(u'Keiner'),
'0': {'description': _(u'Keiner / direkte Abrechnung (Tageswanderung)'),
'trainer_fee': 0,
'pre_meeting_fee': 0,
'trainer_day_fee': 0,
'participant_fee': 0,
'participant_day_fee': 0,
},
'A': {'description': '',
'A': {'description': _(u'A (Mehrtageswanderung Mittelgebirge'),
'trainer_fee': 20,
'pre_meeting_fee': 20,
'trainer_day_fee': 50,
'participant_fee': 10,
'participant_day_fee': 10,
},
'B': {'description': '',
'B': {'description': _(u'B (Alpine Mehrtageswanderung)'),
'trainer_fee': 40,
'pre_meeting_fee': 20,
'trainer_day_fee': 75,
'participant_fee': 10,
'participant_day_fee': 20,
},
'C': {'description': '',
'C': {'description': _(u'C (Tour/Kurs ohne Übernachtung)'),
'trainer_fee': 10,
'pre_meeting_fee': 20,
'trainer_day_fee': 60,
'participant_fee': 10,
'participant_day_fee': 30,
},
'D': {'description': '',
'D': {'description': _(u'D (Tour/Kurs Mittelgebirge)'),
'trainer_fee': 30,
'pre_meeting_fee': 20,
'trainer_day_fee': 75,
'participant_fee': 20,
'participant_day_fee': 40,
},
'E': {'description': '',
'E': {'description': _(u'E (Alpine Klettertour DE/AU)'),
'trainer_fee': 60,
'pre_meeting_fee': 20,
'trainer_day_fee': 75,
'participant_fee': 40,
'participant_day_fee': 40,
},
'F': {'description': '',
'F': {'description': _(u'F (Alpine Klettertour CH/FR/IT)'),
'trainer_fee': 60,
'pre_meeting_fee': 20,
'trainer_day_fee': 85,
'participant_fee': 40,
'participant_day_fee': 45,
},
'G': {'description': '',
'G': {'description': _(u'G (Alpiner Kurs DE/AU)'),
'trainer_fee': 60,
'pre_meeting_fee': 20,
'trainer_day_fee': 75,
'participant_fee': 35,
'participant_day_fee': 30,
},
'H': {'description': '',
'H': {'description': _(u'H (Alpiner Kurs CH/FR/IT/..)'),
'trainer_fee': 60,
'pre_meeting_fee': 20,
'trainer_day_fee': 85,
'participant_fee': 35,
'participant_day_fee': 30,
},
'I': {'description': '',
'I': {'description': _(u'I (Alpine MTB/Ski-Tour DE/AU)'),
'trainer_fee': 60,
'pre_meeting_fee': 20,
'trainer_day_fee': 75,
'participant_fee': 25,
'participant_day_fee': 25,
},
'J': {'description': '',
'J': {'description': _(u'J (Alpine MTB/Ski-Tour CH/FR/IT/..)'),
'trainer_fee': 60,
'pre_meeting_fee': 20,
'trainer_day_fee': 85,
'participant_fee': 25,
'participant_day_fee': 25,
},
'K': {'description': '',
'K': {'description': _(u'K (Ski-Tour/-Kurs mit Liftbenutzung)'),
'trainer_fee': 60,
'pre_meeting_fee': 20,
'trainer_day_fee': 130,

View File

@@ -750,7 +750,11 @@ class TrainerForm(EventCreateForm):
self.fields['trainer_3_email'].widget.attrs['placeholder'] = u'--'
self.fields['trainer_3_phone'].widget.attrs['placeholder'] = u'--'
if DEVELOPMENT_INIT_FORMS:
if hasattr(self._request, 'user') and self._request.user.is_authenticated:
self.fields['trainer_firstname'].initial = self._request.user.first_name
self.fields['trainer_familyname'].initial = self._request.user.last_name
self.fields['trainer_email'].initial = self._request.user.email
elif DEVELOPMENT_INIT_FORMS:
self.fields['trainer_firstname'].initial = self.fields['trainer_firstname'].widget.attrs['placeholder']
self.fields['trainer_familyname'].initial = self.fields['trainer_familyname'].widget.attrs['placeholder']
self.fields['trainer_email'].initial = self.fields['trainer_email'].widget.attrs['placeholder']
@@ -783,7 +787,7 @@ class ChargesForm(EventCreateForm):
label=_(u'Aufwandsentschädigung Trainer*in'),
)
charge = forms.FloatField(label=_(u'Teilnahmegebühr'))
charge = forms.FloatField(label=_(u'Teilnahmegebühr in Euro'))
additional_costs = forms.CharField(required=False,
max_length=config.ADDITIONAL_COSTS_MAX_LENGTH,
@@ -807,7 +811,7 @@ class ChargesForm(EventCreateForm):
pre_meeting_1 = session_data.get('pre_meeting_1', None)
pre_meeting_2 = session_data.get('pre_meeting_2', None)
if ski_lift:
if sport == 'S' and ski_lift:
charge_key = 'K'
elif sport == 'W' and not last_day:
charge_key = '0'
@@ -819,15 +823,15 @@ class ChargesForm(EventCreateForm):
charge_key = 'C'
elif terrain != 'alpine':
charge_key = 'D'
elif mode == 'training' and country in ('DE', 'AU'):
elif mode == 'training' and country in ('DE', 'AUT'):
charge_key = 'G'
elif mode == 'training':
charge_key = 'H'
elif sport == 'K' and country in ('DE', 'AU'):
elif sport == 'K' and country in ('DE', 'AUT'):
charge_key = 'E'
elif sport == 'K':
charge_key = 'F'
elif country in ('DE', 'AU'):
elif country in ('DE', 'AUT'):
charge_key = 'I'
else:
charge_key = 'J'
@@ -875,8 +879,29 @@ class ChargesForm(EventCreateForm):
self.fields['participant_fee'].initial = fees['participant_day_fee']
self.fields['participant_day_fee'].initial = fees['participant_day_fee']
self.fields['trainer_reward'].initial = trainer_reward
self.fields['trainer_reward'].widget.attrs['title'] = (u'%d € Pauschale'
u' + %d Tage * %d € Tagespauschale'
u' + %d halben Anreisetag * %d € Tagespauschale / 2'
u' + %d Vortreffen * %d € Vortreffenpauschale'
% (
fees['trainer_fee'],
ndays, fees['trainer_day_fee'],
int(arrival_previous_day), fees['trainer_day_fee'],
n_pre_meetings, fees['pre_meeting_fee']
)
)
self.fields['charge'].initial = charge
self.fields['charge'].widget.attrs['title'] = (u'%d € Pauschale\n'
u' + %d Tage * %d € Tagespauschale<br />'
u' + %d halben Anreisetag * %d € Tagespauschale / 2'
% (
fees['participant_fee'],
ndays, fees['participant_day_fee'],
int(arrival_previous_day), fees['participant_day_fee'],
)
)
self.fields['additional_costs'].widget.attrs['placeholder'] = ugettext(u'Kann freigelassen werden')
self.fields['additional_costs'].initial = additional_costs_text