1. Made location optional, 2. Added multicountry select option, 3.

Improved form labels, help texts and templates.
This commit is contained in:
2018-02-07 12:54:16 +01:00
parent 9b1d822202
commit 6e77c0b11b
8 changed files with 111 additions and 47 deletions

View File

@@ -39,7 +39,10 @@ class ChoiceSet(object):
class CountryChoiceSet(Countries): class CountryChoiceSet(Countries):
first = ['DE', 'AT', 'CH', 'FR', 'IT'] override = {
'XX': _(u'Länderübergreifend'),
}
first = ['DE', 'AT', 'CH', 'FR', 'IT', 'XX']
first_repeat = True first_repeat = True
first_break = '--' first_break = '--'

View File

@@ -29,24 +29,7 @@ class EventListExportForm(forms.Form):
_(u'Format: tt.mm.jjjj'), _(u'Format: tt.mm.jjjj'),
_(u'Kann frei gelassen werden') _(u'Kann frei gelassen werden')
), ),
widget = DateWidget(attrs={'id': 'id_begin_widget', widget=DateWidget(attrs={'id': 'id_begin_widget',
'placeholder': _(u'Kann freigelassen werden')},
usel10n=True,
options={
# 'format': 'dd.mm.yyyy',
# 'weekStart': 1,
'startView': 3,
'clearBtn': True,
'pickerPosition': 'bottom-left',
},
bootstrap_version=3))
end = forms.DateField(required=False,
label=_(u'Zeitraum - Ende'),
help_text=u'%s - %s' % (
_(u'Format: tt.mm.jjjj'),
_(u'Kann frei gelassen werden')
),
widget = DateWidget(attrs={'id': 'id_end_widget',
'placeholder': _(u'Kann freigelassen werden')}, 'placeholder': _(u'Kann freigelassen werden')},
usel10n=True, usel10n=True,
options={ options={
@@ -57,6 +40,23 @@ class EventListExportForm(forms.Form):
'pickerPosition': 'bottom-left', 'pickerPosition': 'bottom-left',
}, },
bootstrap_version=3)) bootstrap_version=3))
end = forms.DateField(required=False,
label=_(u'Zeitraum - Ende'),
help_text=u'%s - %s' % (
_(u'Format: tt.mm.jjjj'),
_(u'Kann frei gelassen werden')
),
widget=DateWidget(attrs={'id': 'id_end_widget',
'placeholder': _(u'Kann freigelassen werden')},
usel10n=True,
options={
# 'format': 'dd.mm.yyyy',
# 'weekStart': 1,
'startView': 3,
'clearBtn': True,
'pickerPosition': 'bottom-left',
},
bootstrap_version=3))
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(EventListExportForm, self).__init__(*args, **kwargs) super(EventListExportForm, self).__init__(*args, **kwargs)
@@ -232,32 +232,48 @@ class LocationForm(EventCreateForm):
help_text=_(u'Relevant für die Vorauswahl weiterer Felder.'), help_text=_(u'Relevant für die Vorauswahl weiterer Felder.'),
) )
location = forms.CharField(max_length=config.LOCATION_MAX_LENGTH, location = forms.CharField(required=False,
max_length=config.LOCATION_MAX_LENGTH,
label=_(u'Ort'), label=_(u'Ort'),
help_text=_(u'z.B. Orts- und Fels- bzw. Bergname, evtl. auch Region,' help_text=u'%s - %s' % (
u' so dass man mindestens eine grobe Vorstellung bekommt,' _(u'Orts- und Fels- bzw. Bergname, evtl. auch Gebirgsgruppe bzw. Region,'
u' wo das ganze stattfindet.'), u' so dass man mindestens eine grobe Vorstellung bekommt,'
widget=forms.TextInput(attrs={'placeholder': u'Karlsruhe'})) u' wo das ganze stattfindet.'),
_(u'Kann in Ausnahmefällen (z.B. Streckenwanderung) freigelassen werden')
),
widget=forms.TextInput(
attrs={'placeholder': _(u'Kann in Ausnahmefällen frei gelassen werden')}
))
def _proceed_session_data(self, session_data): def _proceed_session_data(self, session_data):
super(LocationForm, self)._proceed_session_data(session_data) super(LocationForm, self)._proceed_session_data(session_data)
sport = session_data.get('sport', None) sport = session_data.get('sport', None)
last_day = session_data.get('last_day', None)
if sport == 'B': if sport == 'B':
self.fields['terrain'].initial = 'alpine' self.fields['terrain'].initial = 'alpine'
self.fields['location'].widget.attrs['placeholder'] = u'Ramsau, Berchtesgadener Alpen' self.fields['country'].initial = 'FR'
self.fields['location'].widget.attrs['placeholder'] = u'z.B. Chamonix, Mont-Blanc-Gruppe'
elif sport == 'K': elif sport == 'K':
self.fields['terrain'].initial = 'crag' self.fields['terrain'].initial = 'crag'
self.fields['location'].widget.attrs['placeholder'] = u'Battert, Baden-Baden' self.fields['location'].widget.attrs['placeholder'] = u'z.B. Battert, Baden-Baden'
elif sport == 'M': elif sport == 'M':
self.fields['location'].widget.attrs['placeholder'] = u'Pfälzerwald' self.fields['terrain'].initial = 'submountains'
self.fields['location'].widget.attrs['placeholder'] = u'z.B. Pfälzerwald'
elif sport == 'S' and last_day:
self.fields['terrain'].initial = 'alpine'
self.fields['country'].initial = 'AT'
self.fields['location'].widget.attrs['placeholder'] = u'z.B. Obergurgl, Ötztaler Alpen'
elif sport == 'S': elif sport == 'S':
self.fields['location'].widget.attrs['placeholder'] = u'Todtnau, Schwarzwald' self.fields['terrain'].initial = 'submountains'
self.fields['location'].widget.attrs['placeholder'] = u'z.B. Todtnau, Schwarzwald'
elif sport == 'W' and last_day:
self.fields['terrain'].initial = 'alpine'
self.fields['country'].initial = 'AT'
self.fields['location'].widget.attrs['placeholder'] = u'z.B. Ötztaler Alpen'
elif sport == 'W': elif sport == 'W':
self.fields['location'].widget.attrs['placeholder'] = u'Maikammer, Pfalz' self.fields['terrain'].initial = 'submountains'
self.fields['location'].widget.attrs['placeholder'] = u'z.B. Maikammer, Pfalz'
if app_config.settings.forms_development_init:
self.fields['location'].initial = self.fields['location'].widget.attrs['placeholder']
class ApproachForm(EventCreateForm): class ApproachForm(EventCreateForm):
@@ -643,10 +659,10 @@ class TrainerForm(EventCreateForm):
def _proceed_session_data(self, session_data): def _proceed_session_data(self, session_data):
super(TrainerForm, self)._proceed_session_data(session_data) super(TrainerForm, self)._proceed_session_data(session_data)
self.fields['trainer_firstname'].widget.attrs['placeholder'] = _(u'Jens') self.fields['trainer_firstname'].widget.attrs['placeholder'] = _(u'Vorname')
self.fields['trainer_familyname'].widget.attrs['placeholder'] = _(u'Kleineheismann') self.fields['trainer_familyname'].widget.attrs['placeholder'] = _(u'Nachname')
self.fields['trainer_email'].widget.attrs['placeholder'] = _(u'heinzel@alpenverein-karlsruhe.de') self.fields['trainer_email'].widget.attrs['placeholder'] = _(u'E-Mail-Adresse')
self.fields['trainer_phone'].widget.attrs['placeholder'] = _(u'0150 150 15 01') self.fields['trainer_phone'].widget.attrs['placeholder'] = _(u'z.B. 0150 150 15 01')
self.fields['trainer_2_fullname'].widget.attrs['placeholder'] = _(u'Kann freigelassen werden') self.fields['trainer_2_fullname'].widget.attrs['placeholder'] = _(u'Kann freigelassen werden')
self.fields['trainer_2_email'].widget.attrs['placeholder'] = u'--' self.fields['trainer_2_email'].widget.attrs['placeholder'] = u'--'
self.fields['trainer_2_phone'].widget.attrs['placeholder'] = u'--' self.fields['trainer_2_phone'].widget.attrs['placeholder'] = u'--'
@@ -659,9 +675,9 @@ class TrainerForm(EventCreateForm):
self.fields['trainer_familyname'].initial = self._request.user.last_name self.fields['trainer_familyname'].initial = self._request.user.last_name
self.fields['trainer_email'].initial = self._request.user.email self.fields['trainer_email'].initial = self._request.user.email
elif app_config.settings.forms_development_init: elif app_config.settings.forms_development_init:
self.fields['trainer_firstname'].initial = self.fields['trainer_firstname'].widget.attrs['placeholder'] self.fields['trainer_firstname'].initial = _(u'Jens')
self.fields['trainer_familyname'].initial = self.fields['trainer_familyname'].widget.attrs['placeholder'] self.fields['trainer_familyname'].initial = _(u'Kleineheismann')
self.fields['trainer_email'].initial = self.fields['trainer_email'].widget.attrs['placeholder'] self.fields['trainer_email'].initial = _(u'heinzel@alpenverein-karlsruhe.de')
class ChargesForm(EventCreateForm): class ChargesForm(EventCreateForm):

View File

@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.9 on 2018-02-07 11:18
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('dav_events', '0008_auto_20180129_1355'),
]
operations = [
migrations.AlterField(
model_name='event',
name='location',
field=models.CharField(blank=True, max_length=250),
),
]

View File

@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.9 on 2018-02-07 11:38
from __future__ import unicode_literals
import dav_events.choices
from django.db import migrations
import django_countries.fields
class Migration(migrations.Migration):
dependencies = [
('dav_events', '0009_auto_20180207_1118'),
]
operations = [
migrations.AlterField(
model_name='event',
name='country',
field=django_countries.fields.CountryField(countries=dav_events.choices.CountryChoiceSet, max_length=2),
),
]

View File

@@ -82,10 +82,11 @@ class Event(models.Model):
course_goal_6 = models.TextField(blank=True) course_goal_6 = models.TextField(blank=True)
# LocationForm # LocationForm
country = CountryField() country = CountryField(countries=choices.CountryChoiceSet)
terrain = models.CharField(max_length=choices.CHOICE_FIELD_MAX_LENGTH, terrain = models.CharField(max_length=choices.CHOICE_FIELD_MAX_LENGTH,
choices=choices.TERRAIN_CHOICES) choices=choices.TERRAIN_CHOICES)
location = models.CharField(max_length=config.LOCATION_MAX_LENGTH) location = models.CharField(max_length=config.LOCATION_MAX_LENGTH,
blank=True)
# ApproachForm # ApproachForm
transport = models.CharField(max_length=choices.CHOICE_FIELD_MAX_LENGTH, transport = models.CharField(max_length=choices.CHOICE_FIELD_MAX_LENGTH,
@@ -308,8 +309,7 @@ class Event(models.Model):
'course_goal_4': self.course_goal_4, 'course_goal_4': self.course_goal_4,
'course_goal_5': self.course_goal_5, 'course_goal_5': self.course_goal_5,
'course_goal_6': self.course_goal_6, 'course_goal_6': self.course_goal_6,
'requirements': self.requirements, 'country': self.country,
'equipment': self.equipment,
'location': self.location, 'location': self.location,
'basecamp': self.basecamp, 'basecamp': self.basecamp,
'accommodation': self.accommodation, 'accommodation': self.accommodation,
@@ -321,13 +321,15 @@ class Event(models.Model):
'meeting_time': self.meeting_time, 'meeting_time': self.meeting_time,
'meeting_point': self.meeting_point, 'meeting_point': self.meeting_point,
'meeting_point_other': self.meeting_point_other, 'meeting_point_other': self.meeting_point_other,
'requirements': self.requirements,
'equipment': self.equipment,
'pre_meeting_1': self.pre_meeting_1, 'pre_meeting_1': self.pre_meeting_1,
'pre_meeting_2': self.pre_meeting_2, 'pre_meeting_2': self.pre_meeting_2,
'deadline': self.deadline,
'min_participants': self.min_participants, 'min_participants': self.min_participants,
'max_participants': self.max_participants, 'max_participants': self.max_participants,
'charge': self.charge, 'charge': self.charge,
'additional_costs': self.additional_costs, 'additional_costs': self.additional_costs,
'deadline': self.deadline,
'trainer_firstname': self.trainer_firstname, 'trainer_firstname': self.trainer_firstname,
'trainer_familyname': self.trainer_familyname, 'trainer_familyname': self.trainer_familyname,
'trainer_email': self.trainer_email, 'trainer_email': self.trainer_email,

View File

@@ -36,7 +36,7 @@ Die Veranstaltung wurde zur Veröffentlichung frei gegeben.
{% if requirements %}<strong>{% trans 'Anforderungen' %}:</strong> {{ requirements }}<br /> {% if requirements %}<strong>{% trans 'Anforderungen' %}:</strong> {{ requirements }}<br />
{% endif %}{% if equipment %}<strong>{% trans 'Ausrüstung' %}:</strong> {{ equipment }}<br /> {% endif %}{% if equipment %}<strong>{% trans 'Ausrüstung' %}:</strong> {{ equipment }}<br />
{% endif %}{% if location %}<strong>{% trans 'Ort' %}:</strong> {{ location }}<br /> {% endif %}{% if location %}<strong>{% trans 'Ort' %}:</strong> {{ location }} {% if country and country != 'DE' and country != 'XX' %}({{ country }}){% endif %}<br />
{% endif %}{% if basecamp %}<strong>{% trans 'Stützpunkt' %}:</strong> {{ basecamp }}<br /> {% endif %}{% if basecamp %}<strong>{% trans 'Stützpunkt' %}:</strong> {{ basecamp }}<br />
{% endif %}{% if accommodation and accommodation != 'NONE' %}<strong>{% trans 'Unterkunft' %}:</strong> {% if accommodation == 'OTHER' %}{{ accommodation_other }}{% else %}{{ event.get_accommodation_display }}{% endif %}<br /> {% endif %}{% if accommodation and accommodation != 'NONE' %}<strong>{% trans 'Unterkunft' %}:</strong> {% if accommodation == 'OTHER' %}{{ accommodation_other }}{% else %}{{ event.get_accommodation_display }}{% endif %}<br />
{% endif %}{% if meals and meals != 'NONE' %}<strong>{% trans 'Verpflegung' %}:</strong> {% if meals == 'OTHER' %}{{ meals_other }}{% else %}{{ event.get_meals_display }}{% endif %}<br /> {% endif %}{% if meals and meals != 'NONE' %}<strong>{% trans 'Verpflegung' %}:</strong> {% if meals == 'OTHER' %}{{ meals_other }}{% else %}{{ event.get_meals_display }}{% endif %}<br />

View File

@@ -70,7 +70,8 @@
<div class="panel-body"> <div class="panel-body">
{% if requirements %}<strong>{% trans 'Anforderungen' %}:</strong> {{ requirements }}<br />{% endif %} {% if requirements %}<strong>{% trans 'Anforderungen' %}:</strong> {{ requirements }}<br />{% endif %}
{% if equipment %}<strong>{% trans 'Ausrüstung' %}:</strong> {{ equipment }}<br />{% endif %} {% if equipment %}<strong>{% trans 'Ausrüstung' %}:</strong> {{ equipment }}<br />{% endif %}
{% if location %}<strong>{% trans 'Ort' %}:</strong> {{ location }}<br />{% endif %} {% if location %}<strong>{% trans 'Ort' %}:</strong> {{ location }}
{% if country and country != 'DE' and country != 'XX' %}({{ country }}){% endif %}<br />{% endif %}
{% if basecamp %}<strong>{% trans 'Stützpunkt' %}:</strong> {{ basecamp }}<br />{% endif %} {% if basecamp %}<strong>{% trans 'Stützpunkt' %}:</strong> {{ basecamp }}<br />{% endif %}
{% if accommodation and accommodation != 'NONE' %} {% if accommodation and accommodation != 'NONE' %}
<strong>{% trans 'Unterkunft' %}:</strong> <strong>{% trans 'Unterkunft' %}:</strong>

View File

@@ -30,7 +30,7 @@
{% endif %} {% endif %}
{% if requirements %}{% trans 'Anforderungen' %}: {{ requirements }} {% if requirements %}{% trans 'Anforderungen' %}: {{ requirements }}
{% endif %}{% if equipment %}{% trans 'Ausrüstung' %}: {{ equipment }} {% endif %}{% if equipment %}{% trans 'Ausrüstung' %}: {{ equipment }}
{% endif %}{% if location %}{% trans 'Ort' %}: {{ location }} {% endif %}{% if location %}{% trans 'Ort' %}: {{ location }} {% if country and country != 'DE' and country != 'XX' %}({{ country }}){% endif %}
{% endif %}{% if basecamp %}{% trans 'Stützpunkt' %}: {{ basecamp }} {% endif %}{% if basecamp %}{% trans 'Stützpunkt' %}: {{ basecamp }}
{% endif %}{% if accommodation and accommodation != 'NONE' %}{% trans 'Unterkunft' %}: {% if accommodation == 'OTHER' %}{{ accommodation_other }}{% else %}{{ event.get_accommodation_display }}{% endif %} {% endif %}{% if accommodation and accommodation != 'NONE' %}{% trans 'Unterkunft' %}: {% if accommodation == 'OTHER' %}{{ accommodation_other }}{% else %}{{ event.get_accommodation_display }}{% endif %}
{% endif %}{% if meals and meals != 'NONE' %}{% trans 'Verpflegung' %}: {% if meals == 'OTHER' %}{{ meals_other }}{% else %}{{ event.get_meals_display }}{% endif %} {% endif %}{% if meals and meals != 'NONE' %}{% trans 'Verpflegung' %}: {% if meals == 'OTHER' %}{{ meals_other }}{% else %}{{ event.get_meals_display }}{% endif %}