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.

97 lines
3.4 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', 'survey_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. class LibraryForm(ModelForm):
  40. class Meta:
  41. model = Library
  42. exclude = ('realname', 'email', 'username', 'type', 'granted',\
  43. 'granted_date', 'survey_mail_send', 'service_id')
  44. class IFGForm(ModelForm):
  45. class Meta:
  46. model = IFG
  47. exclude = ('realname', 'email', 'username', 'granted', 'granted_date',\
  48. 'service_id', 'survey_mail_send')
  49. class HonoraryCertificateForm(ModelForm):
  50. class Meta:
  51. model = HonoraryCertificate
  52. fields = ['request_url', 'project']
  53. # exclude = ('realname', 'email', 'username', 'granted', 'granted_date', 'survey_mail_send')
  54. class LiteratureForm(ModelForm):
  55. class Meta:
  56. model = Literature
  57. fields = ['cost', 'notes', 'info', 'source']
  58. class EmailForm(ModelForm):
  59. # TODO: add some javascript to show/hide other-field
  60. check = BooleanField(required=True,
  61. label=format_html("Ich stimme den <a href='{}'>Nutzungsbedingungen</a> zu",
  62. NUTZUNGSBEDINGUNGEN))
  63. class Meta:
  64. model = Email
  65. fields = ['domain', 'address', 'other']
  66. # exclude = ('realname', 'email', 'username', 'granted', 'granted_date', 'survey_mail_send')
  67. class BusinessCardForm(ModelForm):
  68. class Meta:
  69. model = BusinessCard
  70. fields = ['project', 'data', 'variant', 'sent_to']
  71. class ListForm(ModelForm):
  72. class Meta:
  73. model = List
  74. fields = ['domain', 'address']