from django.db import models
|
|
from django.forms import ModelForm, DateField, ChoiceField, RadioSelect, BooleanField
|
|
from django.contrib.admin.widgets import AdminDateWidget
|
|
from django.utils.html import format_html
|
|
|
|
from .models import Project, Volunteer, Extern, IFG, Library, TYPE_CHOICES,\
|
|
HonoraryCertificate, Travel, Email, Literature, List,\
|
|
BusinessCard
|
|
from .settings import DATAPROTECTION, FOERDERRICHTLINIEN, NUTZUNGSBEDINGUNGEN
|
|
|
|
|
|
|
|
class FdbForm(ModelForm):
|
|
'''this base class provides the required css class for all forms'''
|
|
required_css_class = 'required'
|
|
|
|
|
|
class ProjectForm(FdbForm):
|
|
|
|
# start = DateField(widget=AdminDateWidget())
|
|
|
|
class Meta:
|
|
model = Project
|
|
exclude = ('pid', 'granted', 'granted_date', 'realname', 'email',\
|
|
'end_mail_send', 'status', 'persons')
|
|
widgets = {'start': AdminDateWidget(),
|
|
'end': AdminDateWidget(),}
|
|
|
|
class ExternForm(FdbForm):
|
|
|
|
choice = ChoiceField(choices=TYPE_CHOICES.items(), widget=RadioSelect,
|
|
label='Was möchtest Du beantragen?')
|
|
|
|
check = BooleanField(required=True,
|
|
label=format_html("Ich stimme den <a href='{}'>Datenschutzbestimmungen</a> und den <a href='{}'>Förderrichtlinen</a> zu",
|
|
DATAPROTECTION, FOERDERRICHTLINIEN))
|
|
|
|
class Meta:
|
|
model = Extern
|
|
exclude = ('granted', 'granted_date', 'survey_mail_send', 'service_id')
|
|
|
|
INTERN_CHOICES = {'PRO': 'Projektsteckbrief',
|
|
'HON': 'Ehrenamtsbescheinigung, Akkreditierung oder Redaktionsbestätigung',
|
|
'TRAV': 'Reisekostenerstattung'}
|
|
|
|
class InternForm(FdbForm):
|
|
choice = ChoiceField(choices = INTERN_CHOICES.items(), widget=RadioSelect,
|
|
label = 'Was möchtest Du eingeben?')
|
|
|
|
class Meta:
|
|
model = Volunteer
|
|
exclude = ('granted', 'granted_date', 'survey_mail_send')
|
|
|
|
class TravelForm(FdbForm):
|
|
# TODO: add some javascript to show/hide other-field
|
|
class Meta:
|
|
model = Travel
|
|
exclude = ('granted', 'granted_date', 'survey_mail_send', 'realname', 'email',)
|
|
widgets = {'checkin': AdminDateWidget(),
|
|
'checkout': AdminDateWidget(),}
|
|
|
|
class LibraryForm(FdbForm):
|
|
|
|
class Meta:
|
|
model = Library
|
|
fields = ['cost', 'library', 'duration', 'notes']
|
|
|
|
class HonoraryCertificateForm(FdbForm):
|
|
class Meta:
|
|
model = HonoraryCertificate
|
|
fields = ['request_url', 'project']
|
|
|
|
class IFGForm(FdbForm):
|
|
class Meta:
|
|
model = IFG
|
|
fields = ['cost', 'url', 'notes']
|
|
|
|
|
|
'''TODO: the next four classes could maybe have a common base class for the check field,
|
|
but i am not sure about the sequence of fields. check should be always last'''
|
|
class LiteratureForm(FdbForm):
|
|
check = BooleanField(required=True,
|
|
label=format_html("Ich stimme den <a href='{}'>Nutzungsbedingungen</a> zu",
|
|
NUTZUNGSBEDINGUNGEN))
|
|
|
|
class Meta:
|
|
model = Literature
|
|
fields = ['cost', 'info', 'source', 'notes']
|
|
|
|
class EmailForm(FdbForm):
|
|
# TODO: add some javascript to show/hide other-field
|
|
check = BooleanField(required=True,
|
|
label=format_html("Ich stimme den <a href='{}'>Nutzungsbedingungen</a> zu",
|
|
NUTZUNGSBEDINGUNGEN))
|
|
|
|
class Meta:
|
|
model = Email
|
|
fields = ['domain', 'address', 'other']
|
|
|
|
class BusinessCardForm(FdbForm):
|
|
check = BooleanField(required=True,
|
|
label=format_html("Ich stimme den <a href='{}'>Nutzungsbedingungen</a> zu",
|
|
NUTZUNGSBEDINGUNGEN))
|
|
|
|
class Meta:
|
|
model = BusinessCard
|
|
fields = ['project', 'data', 'variant', 'sent_to']
|
|
|
|
class ListForm(FdbForm):
|
|
check = BooleanField(required=True,
|
|
label=format_html("Ich stimme den <a href='{}'>Nutzungsbedingungen</a> zu",
|
|
NUTZUNGSBEDINGUNGEN))
|
|
|
|
class Meta:
|
|
model = List
|
|
fields = ['domain', 'address']
|