mirror of
https://github.com/ansible/awx.git
synced 2024-11-02 01:21:21 +03:00
Some initial validation logic and documentation on what we require/reject
This commit is contained in:
parent
c1734d74cf
commit
c46f1de347
@ -1318,9 +1318,27 @@ class ScheduleSerializer(BaseSerializer):
|
|||||||
res['unified_job_template'] = ujt.get_absolute_url() #obj.unified_job_template.get_absolute_url()
|
res['unified_job_template'] = ujt.get_absolute_url() #obj.unified_job_template.get_absolute_url()
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
# We reject rrules if:
|
||||||
|
# - DTSTART is not include
|
||||||
|
# - TZID is used
|
||||||
|
# - multiple BYDAY (except WEEKLY), BYMONTHDAY, BYMONTH
|
||||||
|
# - BYDAY prefixed with a number (MO is good but not 20MO)
|
||||||
|
# - BYYEARDAY
|
||||||
|
# - BYWEEKNO
|
||||||
|
# - INTERVAL required
|
||||||
def validate_rrule(self, attrs, source):
|
def validate_rrule(self, attrs, source):
|
||||||
|
rrule_value = attrs[source]
|
||||||
|
if not 'dtstart' in rrule_value.lower():
|
||||||
|
raise serializers.ValidationError('DTSTART required in rrule')
|
||||||
|
if not 'interval' in rrule_value.lower():
|
||||||
|
raise serializers.ValidationError('INTERVAL required in rrule')
|
||||||
|
if 'tzid' in rrule_value.lower():
|
||||||
|
raise serializers.ValidationError('TZID is not supported')
|
||||||
|
|
||||||
|
if 'secondly' in rrule_value.lower():
|
||||||
|
raise serializers.ValidationError('SECONDLY is not supported')
|
||||||
try:
|
try:
|
||||||
sched_rule = rrule.rrulestr(attrs[source])
|
sched_rule = rrule.rrulestr(rrule_value)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
raise serializers.ValidationError("rrule parsing failed validation")
|
raise serializers.ValidationError("rrule parsing failed validation")
|
||||||
return attrs
|
return attrs
|
||||||
|
Loading…
Reference in New Issue
Block a user