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.

94 lines
3.3 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, Literature, List,\
  7. BusinessCard
  8. from .settings import DATAPROTECTION, FOERDERRICHTLINIEN, NUTZUNGSBEDINGUNGEN
  9. class ProjectForm(ModelForm):
  10. # start = DateField(widget=AdminDateWidget())
  11. class Meta:
  12. model = Project
  13. exclude = ('pid', 'granted', 'granted_date', 'realname', 'email', 'project_end_mail', 'survey_mail_send')
  14. widgets = {'start': AdminDateWidget(),
  15. 'end': AdminDateWidget(),}
  16. class ExternForm(ModelForm):
  17. choice = ChoiceField(choices=TYPE_CHOICES.items(), widget=RadioSelect,
  18. label='Was möchtest Du beantragen?')
  19. check = BooleanField(required=True,
  20. label=format_html("Ich stimme den <a href='{}'>Datenschutzbestimmungen</a> und den <a href='{}'>Förderrichtlinen</a> zu",
  21. DATAPROTECTION, FOERDERRICHTLINIEN))
  22. class Meta:
  23. model = Extern
  24. exclude = ('granted', 'granted_date', 'survey_mail_send')
  25. INTERN_CHOICES = [('PRO', 'Projektsteckbrief'),
  26. ('HON', 'Ehrenamtsbescheinigung, Akkreditierung oder Redaktionsbestätigung'),
  27. ('TRAV', 'Reisekostenerstattung')]
  28. class InternForm(ModelForm):
  29. choice = ChoiceField(choices = INTERN_CHOICES, widget=RadioSelect,
  30. label = 'Was möchtest Du eingeben?')
  31. class Meta:
  32. model = Volunteer
  33. exclude = ('granted', 'granted_date', 'survey_mail_send')
  34. class TravelForm(ModelForm):
  35. class Meta:
  36. model = Travel
  37. exclude = ('granted', 'granted_date', 'survey_mail_send', 'realname', 'email',)
  38. class LibraryForm(ModelForm):
  39. class Meta:
  40. model = Library
  41. exclude = ('realname', 'email', 'username', 'type', 'granted', 'granted_date', 'survey_mail_send')
  42. class IFGForm(ModelForm):
  43. class Meta:
  44. model = IFG
  45. exclude = ('realname', 'email', 'username', 'granted', 'granted_date', 'survey_mail_send')
  46. class HonoraryCertificateForm(ModelForm):
  47. class Meta:
  48. model = HonoraryCertificate
  49. fields = ['request_url', 'project']
  50. # exclude = ('realname', 'email', 'username', 'granted', 'granted_date', 'survey_mail_send')
  51. class LiteratureForm(ModelForm):
  52. class Meta:
  53. model = Literature
  54. fields = ['cost', 'notes', 'info', 'source']
  55. class EmailForm(ModelForm):
  56. # TODO: add some javascript to show/hide other-field
  57. check = BooleanField(required=True,
  58. label=format_html("Ich stimme den <a href='{}'>Nutzungsbedingungen</a> zu",
  59. NUTZUNGSBEDINGUNGEN))
  60. class Meta:
  61. model = Email
  62. fields = ['domain', 'address', 'other']
  63. # exclude = ('realname', 'email', 'username', 'granted', 'granted_date', 'survey_mail_send')
  64. class BusinessCardForm(ModelForm):
  65. class Meta:
  66. model = BusinessCard
  67. fields = ['project', 'data', 'variant', 'sent_to']
  68. class ListForm(ModelForm):
  69. class Meta:
  70. model = List
  71. fields = ['domain', 'address']