Projet

Général

Profil

0001-api-manage-optional-parameters-57742.patch

Nicolas Roche, 11 octobre 2021 16:51

Télécharger (1,27 ko)

Voir les différences:

Subject: [PATCH] api: manage optional parameters (#57742)

 chrono/api/serializers.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
chrono/api/serializers.py
195 195
    def validate_category(self, value):
196 196
        try:
197 197
            return Category.objects.get(slug=value)
198 198
        except Category.DoesNotExist:
199 199
            raise serializers.ValidationError(_('unknown category: %s' % value))
200 200

  
201 201
    def validate(self, attrs):
202 202
        super().validate(attrs)
203
        if attrs['minimal_booking_delay_in_working_days'] and attrs.get('kind', 'events') != 'events':
203
        if attrs.get('minimal_booking_delay_in_working_days') and attrs.get('kind', 'events') != 'events':
204 204
            raise ValidationError(
205 205
                {
206 206
                    'minimal_booking_delay_in_working_days': _('Option not available on %s agenda')
207 207
                    % attrs['kind']
208 208
                }
209 209
            )
210 210
        return attrs
211
-