Projet

Général

Profil

0003-trivial-factorize-event-forms-41663.patch

Valentin Deniaud, 12 janvier 2021 16:33

Télécharger (1,51 ko)

Voir les différences:

Subject: [PATCH 3/5] trivial: factorize event forms (#41663)

 chrono/manager/forms.py | 27 +++++----------------------
 1 file changed, 5 insertions(+), 22 deletions(-)
chrono/manager/forms.py
152 152
        fields = ['label', 'slug']
153 153

  
154 154

  
155
class NewEventForm(forms.ModelForm):
156
    class Meta:
157
        model = Event
158
        widgets = {
159
            'publication_date': forms.DateInput(attrs={'type': 'date'}, format='%Y-%m-%d'),
160
        }
161
        fields = [
162
            'start_datetime',
163
            'duration',
164
            'publication_date',
165
            'places',
166
            'waiting_list_places',
167
            'label',
168
            'description',
169
            'pricing',
170
            'url',
171
        ]
172
        field_classes = {
173
            'start_datetime': SplitDateTimeField,
174
        }
175

  
176

  
177 155
class EventForm(forms.ModelForm):
178 156
    class Meta:
179 157
        model = Event
......
197 175
        }
198 176

  
199 177

  
178
class NewEventForm(EventForm):
179
    class Meta(EventForm.Meta):
180
        exclude = ('slug',)
181

  
182

  
200 183
class AgendaResourceForm(forms.Form):
201 184
    resource = forms.ModelChoiceField(label=_('Resource'), queryset=Resource.objects.none())
202 185

  
203
-