From f7b0c7ebb26f29d4bdc379f3a4d67fed79e91f53 Mon Sep 17 00:00:00 2001 From: Valentin Deniaud Date: Thu, 7 Jan 2021 14:05:54 +0100 Subject: [PATCH 3/5] trivial: factorize event forms (#41663) --- chrono/manager/forms.py | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/chrono/manager/forms.py b/chrono/manager/forms.py index 1f850c6..e7a4b12 100644 --- a/chrono/manager/forms.py +++ b/chrono/manager/forms.py @@ -152,28 +152,6 @@ class CategoryEditForm(forms.ModelForm): fields = ['label', 'slug'] -class NewEventForm(forms.ModelForm): - class Meta: - model = Event - widgets = { - 'publication_date': forms.DateInput(attrs={'type': 'date'}, format='%Y-%m-%d'), - } - fields = [ - 'start_datetime', - 'duration', - 'publication_date', - 'places', - 'waiting_list_places', - 'label', - 'description', - 'pricing', - 'url', - ] - field_classes = { - 'start_datetime': SplitDateTimeField, - } - - class EventForm(forms.ModelForm): class Meta: model = Event @@ -197,6 +175,11 @@ class EventForm(forms.ModelForm): } +class NewEventForm(EventForm): + class Meta(EventForm.Meta): + exclude = ('slug',) + + class AgendaResourceForm(forms.Form): resource = forms.ModelChoiceField(label=_('Resource'), queryset=Resource.objects.none()) -- 2.20.1