Forms angepasst und erstellt
This commit is contained in:
parent
b658afba1b
commit
23139fbcca
|
@ -1,10 +1,11 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from frontend.models import Project, PersonGlobalIdentity, PresentationPerson, Presentation
|
from frontend.models import Project, PersonGlobalIdentity, PresentationPerson, Presentation, PresentationEvent
|
||||||
from crispy_forms.helper import FormHelper
|
from crispy_forms.helper import FormHelper
|
||||||
from crispy_forms.layout import Submit, Layout
|
from crispy_forms.layout import Submit, Layout
|
||||||
|
|
||||||
|
|
||||||
from django.forms.models import inlineformset_factory
|
from django.forms.models import inlineformset_factory
|
||||||
|
|
||||||
class NewProjectForm(forms.ModelForm):
|
class NewProjectForm(forms.ModelForm):
|
||||||
|
@ -133,10 +134,59 @@ class PresentationPersonForm(forms.ModelForm):
|
||||||
model = PresentationPerson
|
model = PresentationPerson
|
||||||
fields = [u'given_name', u'additional_name', u'family_name', u'hshmembership']
|
fields = [u'given_name', u'additional_name', u'family_name', u'hshmembership']
|
||||||
|
|
||||||
PresentationPersonFormSet = inlineformset_factory(Presentation, PresentationPerson)
|
class PresentationEventForm(forms.ModelForm):
|
||||||
|
""" Form for the PresentationEventModel"""
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(PresentationPersonForm, self).__init__(*args, **kwargs)
|
||||||
|
self.helper = FormHelper()
|
||||||
|
self.helper.form_class = u'form-horizontal'
|
||||||
|
self.helper.label_class = u'col-lg-2'
|
||||||
|
self.helper.field_class = u'col-lg-4'
|
||||||
|
self.helper.form_method = u'post'
|
||||||
|
self.helper.layout = Layout(
|
||||||
|
u'date',
|
||||||
|
u'name',
|
||||||
|
u'workshop',
|
||||||
|
u'place',
|
||||||
|
u'start_date',
|
||||||
|
u'end_date',
|
||||||
|
Submit(u'send', u'Create', css_class=u'btn-default')
|
||||||
|
)
|
||||||
|
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"Workshop?",
|
||||||
|
required = False,
|
||||||
|
)
|
||||||
|
place = forms.CharField(
|
||||||
|
label = u"Ort",
|
||||||
|
max_length=255 ,
|
||||||
|
required = True,
|
||||||
|
)
|
||||||
|
start_date = forms.DateField(
|
||||||
|
label = u"Startdatum",
|
||||||
|
max_length=255,
|
||||||
|
required = False,
|
||||||
|
)
|
||||||
|
end_date = forms.DateField(
|
||||||
|
label = u"Enddatum",
|
||||||
|
max_length=255,
|
||||||
|
required = False,
|
||||||
|
)
|
||||||
|
class Meta:
|
||||||
|
model = PresentationEvent
|
||||||
|
fields = [u'date', u'name', u'workshop', u'place', u'start_date', u'end_date']
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PresentationForm(forms.Form):
|
class PresentationForm(forms.ModelForm):
|
||||||
""" Big form containing all the stuff about the things. """
|
""" Big form containing all the stuff about the things. """
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(PresentationForm, self).__init__(*args, **kwargs)
|
super(PresentationForm, self).__init__(*args, **kwargs)
|
||||||
|
@ -147,32 +197,20 @@ class PresentationForm(forms.Form):
|
||||||
self.helper.form_method = u'post'
|
self.helper.form_method = u'post'
|
||||||
self.helper.layout = Layout(
|
self.helper.layout = Layout(
|
||||||
u'title',
|
u'title',
|
||||||
u'event_type',
|
u'type',
|
||||||
u'abstract',
|
u'abstract',
|
||||||
u'date',
|
|
||||||
u'rahmen',
|
|
||||||
u'workshop',
|
|
||||||
u'place',
|
|
||||||
u'startdate',
|
|
||||||
u'enddate',
|
|
||||||
u'comments',
|
|
||||||
u'email',
|
|
||||||
Submit(u'send', u'Abschicken', css_class=u'btn-default')
|
Submit(u'send', u'Abschicken', css_class=u'btn-default')
|
||||||
)
|
)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
title = forms.CharField()
|
title = forms.CharField()
|
||||||
event_type = forms.ChoiceField(choices=[(u'new', u'Hauptvortrag'), (u'existing', u'andere Veranstaltung')], initial=u'new', widget=forms.RadioSelect())
|
type = forms.ChoiceField(choices=[(u'new', u'Hauptvortrag'), (u'existing', u'andere Veranstaltung')], initial=u'new', widget=forms.RadioSelect())
|
||||||
abstract = forms.CharField()
|
abstract = forms.CharField()
|
||||||
|
|
||||||
# Event (other event)
|
# Event (other event)
|
||||||
date = forms.DateField()
|
|
||||||
rahmen = forms.CharField()
|
|
||||||
workshop = forms.BooleanField()
|
|
||||||
place = forms.CharField()
|
|
||||||
startdate = forms.DateField()
|
|
||||||
enddate = forms.DateField()
|
|
||||||
|
|
||||||
comments = forms.CharField()
|
comments = forms.CharField()
|
||||||
email = forms.EmailField()
|
email = forms.EmailField()
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = Presentation
|
||||||
|
fields = [u'title', u'type', u'abstract']
|
||||||
|
|
|
@ -19,7 +19,7 @@ class Project(models.Model):
|
||||||
class Presentation(models.Model):
|
class Presentation(models.Model):
|
||||||
""" Presention Model for PresentationForm"""
|
""" Presention Model for PresentationForm"""
|
||||||
title = models.CharField(max_length=255)
|
title = models.CharField(max_length=255)
|
||||||
typ = models.CharField(max_length=255)
|
type = models.CharField(max_length=255)
|
||||||
abstract = models.CharField(max_length=255)
|
abstract = models.CharField(max_length=255)
|
||||||
|
|
||||||
class PresentationEvent(models.Model):
|
class PresentationEvent(models.Model):
|
||||||
|
|
Loading…
Reference in New Issue