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.

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