Skip to content
Snippets Groups Projects

Add API documentation

Merged Konrad Mohrfeldt requested to merge feature/api-docs into master
1 file
+ 13
3
Compare changes
  • Side-by-side
  • Inline
+ 13
3
@@ -22,6 +22,7 @@ from datetime import datetime, time, timedelta
from dateutil.relativedelta import relativedelta
from dateutil.rrule import rrule
from rest_framework.exceptions import ValidationError
from versatileimagefield.fields import PPOIField, VersatileImageField
from django.contrib.auth.models import User
@@ -673,17 +674,26 @@ class Schedule(models.Model):
conflicts = Schedule.make_conflicts(sdl, schedule_pk, show_pk)
if schedule.rrule.freq > 0 and schedule.first_date == schedule.last_date:
return {"detail": _("Start and until dates mustn't be the same")}
raise ValidationError(
_("Start and until dates mustn't be the same"),
code="no-same-day-start-and-end",
)
if schedule.last_date < schedule.first_date:
return {"detail": _("Until date mustn't be before start")}
raise ValidationError(
_("Until date mustn't be before start"),
code="no-start-after-end",
)
num_conflicts = len(
[pr for pr in conflicts["projected"] if len(pr["collisions"]) > 0]
)
if len(solutions) != num_conflicts:
return {"detail": _("Numbers of conflicts and solutions don't match.")}
raise ValidationError(
_("Numbers of conflicts and solutions don't match."),
code="one-solution-per-conflict",
)
# Projected timeslots to create
create = []
Loading