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.2 KiB

4 years ago
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. # TODO: add some javascript to show/hide other-field
  37. class Meta:
  38. model = Travel
  39. exclude = ('granted', 'granted_date', 'survey_mail_send', 'realname', 'email',)
  40. widgets = {'checkin': AdminDateWidget(),
  41. 'checkout': AdminDateWidget(),}
  42. class LibraryForm(ModelForm):
  43. class Meta:
  44. model = Library
  45. fields = ['cost', 'library', 'duration', 'notes']
  46. class IFGForm(ModelForm):
  47. class Meta:
  48. model = IFG
  49. fields = ['cost', 'url', 'notes']
  50. class HonoraryCertificateForm(ModelForm):
  51. class Meta:
  52. model = HonoraryCertificate
  53. fields = ['request_url', 'project']
  54. class LiteratureForm(ModelForm):
  55. class Meta:
  56. model = Literature
  57. fields = ['cost', 'info', 'source', 'notes']
  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. class BusinessCardForm(ModelForm):
  67. class Meta:
  68. model = BusinessCard
  69. fields = ['project', 'data', 'variant', 'sent_to']
  70. class ListForm(ModelForm):
  71. class Meta:
  72. model = List
  73. fields = ['domain', 'address']