Lösungen der Aufgaben vom Kurs MEIM1 - Web Engineering von Prof. Hofmann
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.

forms.py 1.5KB

1234567891011121314151617181920212223242526272829
  1. from django import forms
  2. import datetime
  3. class NoticeForm(forms.Form):
  4. date_formats = ['%d.%m.%Y', '%d.%m.%y']
  5. title = forms.CharField(label='Titel', max_length=80)
  6. text = forms.CharField(label='Text', max_length=400)
  7. start = forms.DateField(label='Von',
  8. input_formats=date_formats,
  9. initial=datetime.date.today)
  10. end = forms.DateField(label='Bis',
  11. input_formats=date_formats,
  12. initial=datetime.datetime.today() + datetime.timedelta(days=1))
  13. class EditNoticeForm(forms.Form):
  14. def __init__(self, *args, **kwargs):
  15. self.title = forms.CharField(label='Titel',
  16. max_length=80,
  17. initial=kwargs.pop('notice_title'))
  18. self.text = forms.CharField(label='Text',
  19. max_length=400,
  20. initial=kwargs.pop('notice_text'))
  21. self.start = forms.DateField(label='Von',
  22. initial=kwargs.pop('notice.pub_start'),
  23. input_formats=NoticeForm.date_formats)
  24. self.end = forms.DateField(label='Bis',
  25. initial=kwargs.pop('pub_end'),
  26. input_formats=NoticeForm.date_formats)
  27. super(EditNoticeForm, self).__init__(*args, **kwargs)