You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.8 KiB

4 years ago
  1. from django.db import models
  2. from django.forms import ModelForm, DateField, ChoiceField, RadioSelect, BooleanField
  3. from django.contrib.admin.widgets import AdminDateWidget
  4. from django.utils.html import format_html
  5. from .models import Project, Volunteer, Extern, IFG, Library, TYPE_CHOICES,\
  6. HonoraryCertificate, Travel, Email
  7. from .settings import DATAPROTECTION, FOERDERRICHTLINIEN, NUTZUNGSBEDINGUNGEN
  8. class ProjectForm(ModelForm):
  9. # start = DateField(widget=AdminDateWidget())
  10. class Meta:
  11. model = Project
  12. exclude = ('pid', 'granted', 'granted_date', 'realname', 'email', 'project_end_mail', 'survey_mail_send')
  13. widgets = {'start': AdminDateWidget(),
  14. 'end': AdminDateWidget(),}
  15. class ExternForm(ModelForm):
  16. choice = ChoiceField(choices=TYPE_CHOICES.items(), widget=RadioSelect,
  17. label='Was möchtest Du beantragen?')
  18. check = BooleanField(required=True,
  19. label=format_html("Ich stimme den <a href='{}'>Datenschutzbestimmungen</a> und den <a href='{}'>Förderrichtlinen</a> zu",
  20. DATAPROTECTION, FOERDERRICHTLINIEN))
  21. class Meta:
  22. model = Extern
  23. exclude = ('granted', 'granted_date', 'survey_mail_send')
  24. INTERN_CHOICES = [('PRO', 'Projektsteckbrief'),
  25. ('HON', 'Ehrenamtsbescheinigung, Akkreditierung oder Redaktionsbestätigung'),
  26. ('TRAV', 'Reisekostenerstattung')]
  27. class InternForm(ModelForm):
  28. choice = ChoiceField(choices = INTERN_CHOICES, widget=RadioSelect,
  29. label = 'Was möchtest Du eingeben?')
  30. class Meta:
  31. model = Volunteer
  32. exclude = ('granted', 'granted_date', 'survey_mail_send')
  33. class TravelForm(ModelForm):
  34. class Meta:
  35. model = Travel
  36. exclude = ('granted', 'granted_date', 'survey_mail_send', 'realname', 'email',)
  37. class LibraryForm(ModelForm):
  38. class Meta:
  39. model = Library
  40. exclude = ('realname', 'email', 'username', 'type', 'granted', 'granted_date', 'survey_mail_send')
  41. class IFGForm(ModelForm):
  42. class Meta:
  43. model = IFG
  44. exclude = ('realname', 'email', 'username', 'granted', 'granted_date', 'survey_mail_send')
  45. class HonoraryCertificateForm(ModelForm):
  46. class Meta:
  47. model = HonoraryCertificate
  48. exclude = ('realname', 'email', 'username', 'granted', 'granted_date', 'survey_mail_send')
  49. class EmailForm(ModelForm):
  50. # TODO: add some javascript to show/hide other-field
  51. check = BooleanField(required=True,
  52. label=format_html("Ich stimme den <a href='{}'>Nutzungsbedingungen</a> zu",
  53. NUTZUNGSBEDINGUNGEN))
  54. class Meta:
  55. model = Email
  56. exclude = ('realname', 'email', 'username', 'granted', 'granted_date', 'survey_mail_send')