1
0
Fork 0
foerderbarometer/input/forms.py

95 lines
3.3 KiB
Python
Raw Normal View History

2020-09-29 07:54:31 +00:00
from django.db import models
2020-10-20 11:16:03 +00:00
from django.forms import ModelForm, DateField, ChoiceField, RadioSelect, BooleanField
2020-09-29 10:16:10 +00:00
from django.contrib.admin.widgets import AdminDateWidget
from django.utils.html import format_html
2020-09-29 10:16:10 +00:00
2020-10-27 10:00:58 +00:00
from .models import Project, Volunteer, Extern, IFG, Library, TYPE_CHOICES,\
HonoraryCertificate, Travel, Email, Literature, List,\
BusinessCard
2020-10-27 10:00:58 +00:00
from .settings import DATAPROTECTION, FOERDERRICHTLINIEN, NUTZUNGSBEDINGUNGEN
2020-09-29 07:54:31 +00:00
class ProjectForm(ModelForm):
2020-09-29 10:16:10 +00:00
# start = DateField(widget=AdminDateWidget())
2020-09-29 10:16:10 +00:00
2020-09-29 07:54:31 +00:00
class Meta:
model = Project
exclude = ('pid', 'granted', 'granted_date', 'realname', 'email', 'project_end_mail', 'survey_mail_send')
widgets = {'start': AdminDateWidget(),
'end': AdminDateWidget(),}
2020-10-01 08:51:19 +00:00
class ExternForm(ModelForm):
2020-10-01 08:51:19 +00:00
choice = ChoiceField(choices=TYPE_CHOICES.items(), widget=RadioSelect,
2020-10-19 12:46:58 +00:00
label='Was möchtest Du beantragen?')
2020-10-01 08:51:19 +00: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 11:16:03 +00:00
2020-10-01 08:51:19 +00:00
class Meta:
model = Extern
2020-10-22 14:02:59 +00:00
exclude = ('granted', 'granted_date', 'survey_mail_send')
2020-10-01 08:51:19 +00:00
2020-10-21 07:54:12 +00:00
INTERN_CHOICES = [('PRO', 'Projektsteckbrief'),
('HON', 'Ehrenamtsbescheinigung, Akkreditierung oder Redaktionsbestätigung'),
2020-10-21 07:54:12 +00:00
('TRAV', 'Reisekostenerstattung')]
class InternForm(ModelForm):
choice = ChoiceField(choices = INTERN_CHOICES, widget=RadioSelect,
label = 'Was möchtest Du eingeben?')
class Meta:
model = Volunteer
2020-10-22 14:02:59 +00:00
exclude = ('granted', 'granted_date', 'survey_mail_send')
2020-10-21 07:54:12 +00:00
2020-10-26 10:38:56 +00:00
class TravelForm(ModelForm):
class Meta:
model = Travel
exclude = ('granted', 'granted_date', 'survey_mail_send', 'realname', 'email',)
2020-10-21 07:54:12 +00:00
2020-10-01 10:08:02 +00:00
class LibraryForm(ModelForm):
2020-10-19 11:29:36 +00:00
2020-10-01 08:51:19 +00:00
class Meta:
model = Library
2020-10-22 14:02:59 +00:00
exclude = ('realname', 'email', 'username', 'type', 'granted', 'granted_date', 'survey_mail_send')
2020-10-01 08:51:19 +00:00
2020-10-01 10:08:02 +00:00
class IFGForm(ModelForm):
2020-10-01 08:51:19 +00:00
class Meta:
2020-10-01 10:08:02 +00:00
model = IFG
2020-10-22 14:02:59 +00:00
exclude = ('realname', 'email', 'username', 'granted', 'granted_date', 'survey_mail_send')
2020-10-21 07:54:12 +00:00
class HonoraryCertificateForm(ModelForm):
class Meta:
model = HonoraryCertificate
fields = ['request_url', 'project']
# exclude = ('realname', 'email', 'username', 'granted', 'granted_date', 'survey_mail_send')
2020-10-27 10:00:58 +00:00
class LiteratureForm(ModelForm):
class Meta:
model = Literature
fields = ['cost', 'notes', 'info', 'source']
2020-10-27 10:00:58 +00:00
class EmailForm(ModelForm):
# 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']
# exclude = ('realname', 'email', 'username', 'granted', 'granted_date', 'survey_mail_send')
class BusinessCardForm(ModelForm):
class Meta:
model = BusinessCard
fields = ['project', 'data', 'variant', 'sent_to']
class ListForm(ModelForm):
class Meta:
model = List
fields = ['domain', 'address']