diff --git a/frontend/admin.py b/frontend/admin.py index cd2872c..e20706c 100644 --- a/frontend/admin.py +++ b/frontend/admin.py @@ -1,8 +1,17 @@ # -*- coding: utf-8 -*- from django.contrib import admin -from frontend.models import Project, PersonGlobalIdentity, CitaviProjectIdentity + +from frontend.models import Project, PersonGlobalIdentity, CitaviProjectIdentity, HSHIdentity, VIVOIdentity admin.site.register(Project) admin.site.register(PersonGlobalIdentity) -admin.site.register(CitaviProjectIdentity) \ No newline at end of file +admin.site.register(CitaviProjectIdentity) +admin.site.register(HSHIdentity) +admin.site.register(VIVOIdentity) + +from frontend.models import Presentation, PresentationEvent, PresentationPerson, PresentationSubmission +admin.site.register(Presentation) +admin.site.register(PresentationEvent) +admin.site.register(PresentationPerson) +admin.site.register(PresentationSubmission) diff --git a/frontend/forms.py b/frontend/forms.py index 1b78833..dd676de 100644 --- a/frontend/forms.py +++ b/frontend/forms.py @@ -93,40 +93,40 @@ 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'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'] """ FormHelper for the PresentationEventForm""" @@ -143,39 +143,39 @@ 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 , +# ) +# 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 PresentationSubmissionForm(forms.ModelForm): """ Form for the PresentationSubmission""" diff --git a/frontend/formsets.py b/frontend/formsets.py index 7c365cf..1a83e57 100644 --- a/frontend/formsets.py +++ b/frontend/formsets.py @@ -2,6 +2,8 @@ from django import forms from frontend.models import Presentation, PresentationEvent, PresentationPerson from django.forms.models import inlineformset_factory +from bootstrap3_datetime.widgets import DateTimePicker + PresentationPersonInlineFormset = inlineformset_factory( Presentation, @@ -15,5 +17,10 @@ PresentationEventInlineFormset = inlineformset_factory( Presentation, PresentationEvent, extra=1, - can_delete=False -) \ No newline at end of file + 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}) + } +) diff --git a/frontend/models.py b/frontend/models.py index fc5ff43..69467a6 100644 --- a/frontend/models.py +++ b/frontend/models.py @@ -22,12 +22,19 @@ class Presentation(models.Model): type = models.CharField(max_length=255, choices=((u'main', u'Hauptvortrag'), (u'other', u'andere Veranstaltung')), default=u'main', verbose_name='Veranstaltungstyp') abstract = models.TextField(verbose_name=u'Zusammenfassung') + def __unicode__(self): + return self.title + class PresentationSubmission(models.Model): """ Submission containing a Presentation """ email = models.EmailField(max_length=255, verbose_name='E-Mail Adresse') comment = models.TextField(verbose_name=u'Kommentar') presentation = models.ForeignKey(Presentation, blank=False, null=False, db_index=True) + def __unicode__(self): + return self.email + + class PresentationEvent(models.Model): """Veranstaltung""" date = models.DateField(verbose_name='Veranstaltungsdatum') @@ -38,6 +45,9 @@ class PresentationEvent(models.Model): end_date = models.DateField(verbose_name='Enddatum') presentation = models.ForeignKey(Presentation, blank=False, null=False, db_index=True) + def __unicode__(self): + return self.name + class PresentationPerson(models.Model): """ Person Model for PresentationForm""" given_name = models.CharField(max_length=255, verbose_name='Vorname') @@ -46,6 +56,9 @@ class PresentationPerson(models.Model): hshmembership = models.CharField(max_length=255, choices=((u'yes', u'Ja'), (u'no', u'Nein'), (u'maybe', u'Maybe')), default=u'maybe', verbose_name='Hochschulangehörigkeit') presentation = models.ForeignKey(Presentation, blank=False, null=False, db_index=True) + def __unicode__(self): + return self.given_name + ' ' + self.family_name + class PersonGlobalIdentity(models.Model): """ Model representing a global person identity in django. Can be used to link any foreign identity to it. """ diff --git a/frontend/templates/presentation-add.html b/frontend/templates/presentation-add.html index 725a595..15b1cf4 100644 --- a/frontend/templates/presentation-add.html +++ b/frontend/templates/presentation-add.html @@ -23,6 +23,7 @@ }); }) + {{ event_formset.media }} {% endblock %} {% block content %} {% if success %} diff --git a/frontend/views.py b/frontend/views.py index 60e90a3..4d0a10e 100644 --- a/frontend/views.py +++ b/frontend/views.py @@ -15,7 +15,7 @@ from django.contrib.auth.views import login, logout from django.core.urlresolvers import reverse from frontend.forms import NewProjectForm, FileUploadForm, PersonMapForm -from frontend.forms import PresentationForm, PresentationEventForm, PresentationPersonForm, PresentationSubmissionForm +from frontend.forms import PresentationForm, PresentationSubmissionForm from frontend.forms import PresentationEventFormHelper, PresentationPersonFormHelper from frontend.models import Presentation, PresentationEvent, PresentationPerson from frontend.formsets import PresentationEventInlineFormset, PresentationPersonInlineFormset @@ -177,7 +177,6 @@ class PresentationAddView(ProtectedTemplateView): person_ok = self.person_formset.is_valid() """ Only other event type needs a valid event formset. """ print(presentation_ok, person_ok, event_ok, submission_ok) - print(self.submission_form) if presentation_ok and self.presentation_form.cleaned_data[u'type'] == 'other': event_ok = self.event_formset.is_valid() else: