Project

General

Profile

« Previous | Next » 

Revision 00ad70aa

Added by Serghei Mihai over 10 years ago

personnes: group holidays services saved correctly

Closes #4110

View differences:

calebasse/personnes/forms.py
227 227
        super(GroupHolidayBaseFormSet, self).__init__(*args, **kwargs)
228 228

  
229 229
class GroupHolidayForm(forms.ModelForm):
230
    for_all_services = forms.BooleanField(required=False, initial=True)
231 230

  
232 231
    def __init__(self, *args, **kwargs):
233 232
        self.service = kwargs.pop('service', None)
234 233
        super(GroupHolidayForm, self).__init__(*args, **kwargs)
235
        if self.instance and self.instance.id:
236
            self.initial['for_all_services'] = self.instance.services.count() == Service.objects.count()
237 234
        self.fields['holiday_type'].queryset = \
238 235
                HolidayType.objects.filter(for_group=True)
239 236

  
240

  
241
    def save(self, commit=True):
242
        instance = super(GroupHolidayForm, self).save(commit=False)
243
        if commit:
244
            instance.save()
245
        return instance
246

  
247 237
    class Meta:
248 238
        model = Holiday
249 239
        widgets = {

Also available in: Unified diff