2020-09-29 09:54:31 +02:00
|
|
|
from django.db import models
|
2020-10-20 13:16:03 +02:00
|
|
|
from django.forms import ModelForm, DateField, ChoiceField, RadioSelect, BooleanField
|
2020-09-29 12:16:10 +02:00
|
|
|
from django.contrib.admin.widgets import AdminDateWidget
|
2020-10-20 14:12:12 +02:00
|
|
|
from django.utils.html import format_html
|
2020-09-29 12:16:10 +02:00
|
|
|
|
2020-10-27 11:00:58 +01:00
|
|
|
from .models import Project, Volunteer, Extern, IFG, Library, TYPE_CHOICES,\
|
2020-10-27 13:47:46 +01:00
|
|
|
HonoraryCertificate, Travel, Email, Literature, List,\
|
|
|
|
BusinessCard
|
2020-10-27 11:00:58 +01:00
|
|
|
from .settings import DATAPROTECTION, FOERDERRICHTLINIEN, NUTZUNGSBEDINGUNGEN
|
2020-10-20 14:12:12 +02:00
|
|
|
|
2020-09-29 09:54:31 +02:00
|
|
|
|
2020-11-17 16:11:10 +01:00
|
|
|
|
|
|
|
class FdbForm(ModelForm):
|
|
|
|
'''this base class provides the required css class for all forms'''
|
|
|
|
required_css_class = 'required'
|
|
|
|
|
|
|
|
|
|
|
|
class ProjectForm(FdbForm):
|
2020-09-29 12:16:10 +02:00
|
|
|
|
2020-10-21 13:53:39 +02:00
|
|
|
# start = DateField(widget=AdminDateWidget())
|
2020-09-29 12:16:10 +02:00
|
|
|
|
2020-09-29 09:54:31 +02:00
|
|
|
class Meta:
|
|
|
|
model = Project
|
2020-10-29 13:14:06 +01:00
|
|
|
exclude = ('pid', 'granted', 'granted_date', 'realname', 'email',\
|
2020-11-02 11:56:07 +01:00
|
|
|
'end_mail_send', 'status', 'persons')
|
2020-10-21 13:53:39 +02:00
|
|
|
widgets = {'start': AdminDateWidget(),
|
|
|
|
'end': AdminDateWidget(),}
|
2020-10-01 10:51:19 +02:00
|
|
|
|
2020-11-17 16:11:10 +01:00
|
|
|
class ExternForm(FdbForm):
|
2020-10-01 10:51:19 +02:00
|
|
|
|
2020-10-21 13:27:05 +02:00
|
|
|
choice = ChoiceField(choices=TYPE_CHOICES.items(), widget=RadioSelect,
|
2020-10-19 14:46:58 +02:00
|
|
|
label='Was möchtest Du beantragen?')
|
2020-10-01 10:51:19 +02:00
|
|
|
|
2020-10-20 14:12:12 +02:00
|
|
|
check = BooleanField(required=True,
|
|
|
|
label=format_html("Ich stimme den <a href='{}'>Datenschutzbestimmungen</a> und den <a href='{}'>Förderrichtlinen</a> zu",
|
|
|
|
DATAPROTECTION, FOERDERRICHTLINIEN))
|
2020-10-20 13:16:03 +02:00
|
|
|
|
2020-10-01 10:51:19 +02:00
|
|
|
class Meta:
|
2020-10-26 12:06:26 +01:00
|
|
|
model = Extern
|
2020-10-29 15:05:11 +01:00
|
|
|
exclude = ('granted', 'granted_date', 'survey_mail_send', 'service_id')
|
2020-10-01 10:51:19 +02:00
|
|
|
|
2020-10-28 15:04:53 +01:00
|
|
|
INTERN_CHOICES = {'PRO': 'Projektsteckbrief',
|
|
|
|
'HON': 'Ehrenamtsbescheinigung, Akkreditierung oder Redaktionsbestätigung',
|
|
|
|
'TRAV': 'Reisekostenerstattung'}
|
2020-10-21 09:54:12 +02:00
|
|
|
|
2020-11-17 16:11:10 +01:00
|
|
|
class InternForm(FdbForm):
|
2020-10-28 15:04:53 +01:00
|
|
|
choice = ChoiceField(choices = INTERN_CHOICES.items(), widget=RadioSelect,
|
2020-10-21 09:54:12 +02:00
|
|
|
label = 'Was möchtest Du eingeben?')
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = Volunteer
|
2020-10-22 16:02:59 +02:00
|
|
|
exclude = ('granted', 'granted_date', 'survey_mail_send')
|
2020-10-21 09:54:12 +02:00
|
|
|
|
2020-11-17 16:11:10 +01:00
|
|
|
class TravelForm(FdbForm):
|
2020-11-03 12:56:40 +01:00
|
|
|
# TODO: add some javascript to show/hide other-field
|
2020-10-26 11:38:56 +01:00
|
|
|
class Meta:
|
|
|
|
model = Travel
|
|
|
|
exclude = ('granted', 'granted_date', 'survey_mail_send', 'realname', 'email',)
|
2020-11-02 14:04:01 +01:00
|
|
|
widgets = {'checkin': AdminDateWidget(),
|
|
|
|
'checkout': AdminDateWidget(),}
|
2020-10-21 09:54:12 +02:00
|
|
|
|
2020-11-17 16:11:10 +01:00
|
|
|
class LibraryForm(FdbForm):
|
2020-10-19 13:29:36 +02:00
|
|
|
|
2020-10-01 10:51:19 +02:00
|
|
|
class Meta:
|
|
|
|
model = Library
|
2020-11-02 15:41:08 +01:00
|
|
|
fields = ['cost', 'library', 'duration', 'notes']
|
2020-10-01 10:51:19 +02:00
|
|
|
|
2020-11-17 16:11:10 +01:00
|
|
|
class IFGForm(FdbForm):
|
2020-10-01 10:51:19 +02:00
|
|
|
class Meta:
|
2020-10-01 12:08:02 +02:00
|
|
|
model = IFG
|
2020-11-02 15:41:08 +01:00
|
|
|
fields = ['cost', 'url', 'notes']
|
2020-10-21 09:54:12 +02:00
|
|
|
|
2020-11-17 16:11:10 +01:00
|
|
|
class HonoraryCertificateForm(FdbForm):
|
2020-10-21 09:54:12 +02:00
|
|
|
class Meta:
|
|
|
|
model = HonoraryCertificate
|
2020-10-27 12:37:18 +01:00
|
|
|
fields = ['request_url', 'project']
|
2020-10-27 11:00:58 +01:00
|
|
|
|
2020-11-17 16:11:10 +01:00
|
|
|
class LiteratureForm(FdbForm):
|
2020-10-27 13:47:46 +01:00
|
|
|
class Meta:
|
|
|
|
model = Literature
|
2020-11-02 15:41:08 +01:00
|
|
|
fields = ['cost', 'info', 'source', 'notes']
|
2020-10-27 13:47:46 +01:00
|
|
|
|
2020-11-18 16:50:58 +01:00
|
|
|
|
|
|
|
'''TODO: the next three 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'''
|
2020-11-17 16:11:10 +01:00
|
|
|
class EmailForm(FdbForm):
|
2020-10-27 11:00:58 +01:00
|
|
|
# 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
|
2020-10-27 12:37:18 +01:00
|
|
|
fields = ['domain', 'address', 'other']
|
2020-10-27 13:47:46 +01:00
|
|
|
|
2020-11-17 16:11:10 +01:00
|
|
|
class BusinessCardForm(FdbForm):
|
2020-11-18 16:50:58 +01:00
|
|
|
check = BooleanField(required=True,
|
|
|
|
label=format_html("Ich stimme den <a href='{}'>Nutzungsbedingungen</a> zu",
|
|
|
|
NUTZUNGSBEDINGUNGEN))
|
|
|
|
|
2020-10-27 13:47:46 +01:00
|
|
|
class Meta:
|
|
|
|
model = BusinessCard
|
|
|
|
fields = ['project', 'data', 'variant', 'sent_to']
|
|
|
|
|
2020-11-17 16:11:10 +01:00
|
|
|
class ListForm(FdbForm):
|
2020-11-18 16:50:58 +01:00
|
|
|
check = BooleanField(required=True,
|
|
|
|
label=format_html("Ich stimme den <a href='{}'>Nutzungsbedingungen</a> zu",
|
|
|
|
NUTZUNGSBEDINGUNGEN))
|
|
|
|
|
2020-10-27 13:47:46 +01:00
|
|
|
class Meta:
|
|
|
|
model = List
|
|
|
|
fields = ['domain', 'address']
|