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