diff --git a/citavi_mapper/settings.py b/citavi_mapper/settings.py index 3de8363..0b82291 100644 --- a/citavi_mapper/settings.py +++ b/citavi_mapper/settings.py @@ -47,11 +47,10 @@ INSTALLED_APPS = ( 'django.contrib.staticfiles', 'pipeline', 'crispy_forms', - 'fancy_formsets', 'bootstrap3_datetime', 'django_bootstrap_breadcrumbs', 'frontend', - 'debug_toolbar' +# 'debug_toolbar' ) MIDDLEWARE_CLASSES = ( diff --git a/frontend/forms.py b/frontend/forms.py index dd676de..3c3ca23 100644 --- a/frontend/forms.py +++ b/frontend/forms.py @@ -4,6 +4,7 @@ from django import forms from frontend.models import Project, PersonGlobalIdentity, PresentationPerson, Presentation, PresentationEvent, PresentationSubmission from crispy_forms.helper import FormHelper from crispy_forms.layout import Submit, Layout +from bootstrap3_datetime.widgets import DateTimePicker class NewProjectForm(forms.ModelForm): def __init__(self, *args, **kwargs): @@ -93,40 +94,41 @@ PresentationPersonFormHelper.layout = Layout( u'hshmembership' ) -# class PresentationPersonForm(forms.ModelForm): -# """ Modelform for PresentationPerson """ -# def __init__(self, *args, **kwargs): -# super(PresentationPersonForm, self).__init__(*args, **kwargs) -# self.helper = PresentationPersonFormHelper -# -# given_name = forms.CharField( -# label=u"Vorname", -# max_length=255, -# required=True, -# ) -# -# additional_name = forms.CharField( -# label=u"Zweiter Vorname/Zusatz", -# max_length=255, -# required=False, -# ) -# -# family_name = forms.CharField( -# label=u"Nachname", -# max_length=255, -# required=True, -# ) -# -# hshmembership = forms.TypedChoiceField( -# choices=((u'yes', u'Ja'), (u'no', u'Nein'), (u'maybe', u'Maybe')), -# initial=u'maybe', -# required=True, -# widget=forms.RadioSelect() -# ) -# -# class Meta: -# model = PresentationPerson -# fields = [u'given_name', u'additional_name', u'family_name', u'hshmembership'] +class PresentationPersonForm(forms.ModelForm): + """ Modelform for PresentationPerson """ + def __init__(self, *args, **kwargs): + super(PresentationPersonForm, self).__init__(*args, **kwargs) + self.helper = PresentationPersonFormHelper + + given_name = forms.CharField( + label=u"Vorname", + max_length=255, + required=True, + ) + + additional_name = forms.CharField( + label=u"Zweiter Vorname/Zusatz", + max_length=255, + required=False, + ) + + family_name = forms.CharField( + label=u"Nachname", + max_length=255, + required=True, + ) + + hshmembership = forms.TypedChoiceField( + choices=((u'yes', u'Ja'), (u'no', u'Nein'), (u'maybe', u'Vielleicht')), + initial=u'maybe', + label=u'Hochschulangehörigkeit', + required=True, + widget=forms.RadioSelect() + ) + + class Meta: + model = PresentationPerson + fields = [u'given_name', u'additional_name', u'family_name', u'hshmembership'] """ FormHelper for the PresentationEventForm""" @@ -143,39 +145,43 @@ PresentationEventFormHelper.layout = Layout( u'end_date' ) -# class PresentationEventForm(forms.ModelForm): -# """ Form for the PresentationEventModel""" -# def __init__(self, *args, **kwargs): -# super(PresentationEventForm, self).__init__(*args, **kwargs) -# self.helper = PresentationEventFormHelper -# -# date = forms.DateField( -# label=u"Datum", -# required=True , -# ) -# name = forms.CharField( -# label=u"Rahmen der Veranstaltung", -# max_length=255, -# required=True, -# ) -# workshop = forms.BooleanField( -# label=u"Veranstaltung ist ein Workshop", -# required=False, -# ) -# place = forms.CharField( -# label=u"Ort", -# max_length=255 , -# required=True, -# ) -# start_date = forms.DateField( -# label=u"Startdatum" -# ) -# end_date = forms.DateField( -# label=u"Enddatum" -# ) -# class Meta: -# model = PresentationEvent -# fields = [u'date', u'name', u'workshop', u'place', u'start_date', u'end_date'] +class PresentationEventForm(forms.ModelForm): + """ Form for the PresentationEventModel""" + def __init__(self, *args, **kwargs): + super(PresentationEventForm, self).__init__(*args, **kwargs) + self.helper = PresentationEventFormHelper + + date = forms.DateField( + label=u"Datum", + required=True, + help_text='Geben Sie hier das Datum des Vortrags (wenigstens das Jahr) an', + widget=DateTimePicker(options={"format": "YYYY-MM-DD", 'pickSeconds': False}) + ) + name = forms.CharField( + label=u"Rahmen der Veranstaltung", + max_length=255, + required=True, + ) + workshop = forms.BooleanField( + label=u"Veranstaltung ist ein Workshop", + required=False, + ) + place = forms.CharField( + label=u"Ort", + max_length=255 , + required=True, + ) + start_date = forms.DateField( + label=u"Startdatum", + widget=DateTimePicker(options={"format": "YYYY-MM-DD", 'pickSeconds': False}) + ) + end_date = forms.DateField( + label=u"Enddatum", + widget=DateTimePicker(options={"format": "YYYY-MM-DD", 'pickSeconds': False}) + ) + class Meta: + model = PresentationEvent + fields = [u'date', u'name', u'workshop', u'place', u'start_date', u'end_date'] class PresentationSubmissionForm(forms.ModelForm): """ Form for the PresentationSubmission""" @@ -213,7 +219,7 @@ class PresentationForm(forms.ModelForm): u'abstract' ) - title = forms.CharField(label='Titel') + title = forms.CharField(label='Titel', help_text='Geben Sie bitte hier den vollständigen Titel des Vortrags an') type = forms.ChoiceField(choices=[(u'main', u'Hauptvortrag'), (u'other', u'andere Veranstaltung')], initial=u'main', widget=forms.RadioSelect(), label='Veranstaltungstyp') abstract = forms.TextInput() diff --git a/frontend/formsets.py b/frontend/formsets.py index 1a83e57..6e0e5c6 100644 --- a/frontend/formsets.py +++ b/frontend/formsets.py @@ -1,26 +1,19 @@ -from django import forms from frontend.models import Presentation, PresentationEvent, PresentationPerson +from frontend.forms import PresentationEventForm, PresentationPersonForm from django.forms.models import inlineformset_factory -from bootstrap3_datetime.widgets import DateTimePicker - - PresentationPersonInlineFormset = inlineformset_factory( Presentation, PresentationPerson, + form=PresentationPersonForm, extra=1, - can_delete=False, - widgets={'hshmembership': forms.RadioSelect} + can_delete=False ) PresentationEventInlineFormset = inlineformset_factory( Presentation, PresentationEvent, + form=PresentationEventForm, extra=1, - can_delete=False, - widgets={ - 'date': DateTimePicker(options={"format": "YYYY-MM-DD", 'pickSeconds': False}), - 'start_date': DateTimePicker(options={"format": "YYYY-MM-DD", 'pickSeconds': False}), - 'end_date': DateTimePicker(options={"format": "YYYY-MM-DD", 'pickSeconds': False}) - } + can_delete=False ) diff --git a/frontend/templates/presentation-add.html b/frontend/templates/presentation-add.html index 15b1cf4..6d453e6 100644 --- a/frontend/templates/presentation-add.html +++ b/frontend/templates/presentation-add.html @@ -23,6 +23,11 @@ }); }) + {{ event_formset.media }} {% endblock %} {% block content %} @@ -72,7 +77,7 @@
{% crispy submission_form %}
- +
zurück zum Index