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.

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