add duration to eventsession constraints
This commit is contained in:
parent
9fce167c7c
commit
daefd62f96
|
@ -1,4 +1,4 @@
|
||||||
# Generated by Django 3.0.3 on 2020-06-22 00:06
|
# Generated by Django 3.0.3 on 2020-06-22 08:51
|
||||||
|
|
||||||
import django.contrib.postgres.constraints
|
import django.contrib.postgres.constraints
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
@ -11,6 +11,10 @@ class Migration(migrations.Migration):
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
migrations.RemoveConstraint(
|
||||||
|
model_name="eventsession",
|
||||||
|
name="prevent_event_session_event_type_event_location_overlaps",
|
||||||
|
),
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
model_name="event",
|
model_name="event",
|
||||||
name="duration_minutes",
|
name="duration_minutes",
|
||||||
|
@ -32,8 +36,21 @@ class Migration(migrations.Migration):
|
||||||
model_name="eventsession",
|
model_name="eventsession",
|
||||||
constraint=django.contrib.postgres.constraints.ExclusionConstraint(
|
constraint=django.contrib.postgres.constraints.ExclusionConstraint(
|
||||||
expressions=[
|
expressions=[
|
||||||
|
("when", "&&"),
|
||||||
("event_location", "="),
|
("event_location", "="),
|
||||||
("event_type", "="),
|
("event_type", "="),
|
||||||
|
("event_duration_minutes", "="),
|
||||||
|
],
|
||||||
|
name="prevent_event_session_event_type_event_location_overlaps",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AddConstraint(
|
||||||
|
model_name="eventsession",
|
||||||
|
constraint=django.contrib.postgres.constraints.ExclusionConstraint(
|
||||||
|
expressions=[
|
||||||
|
("event_location", "="),
|
||||||
|
("event_type", "="),
|
||||||
|
("event_duration_minutes", "="),
|
||||||
("when", "-|-"),
|
("when", "-|-"),
|
||||||
],
|
],
|
||||||
name="prevent_adjacent_eventsessions",
|
name="prevent_adjacent_eventsessions",
|
||||||
|
|
|
@ -833,21 +833,23 @@ class EventSession(CampRelatedModel):
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ["when", "event_type", "event_location"]
|
ordering = ["when", "event_type", "event_location"]
|
||||||
constraints = [
|
constraints = [
|
||||||
# We do not want overlapping sessions for the same EventType/EventLocation combo.
|
# We do not want overlapping sessions for the same EventType/EventLocation/duration combo.
|
||||||
ExclusionConstraint(
|
ExclusionConstraint(
|
||||||
name="prevent_event_session_event_type_event_location_overlaps",
|
name="prevent_event_session_event_type_event_location_overlaps",
|
||||||
expressions=[
|
expressions=[
|
||||||
("when", RangeOperators.OVERLAPS),
|
("when", RangeOperators.OVERLAPS),
|
||||||
("event_location", RangeOperators.EQUAL),
|
("event_location", RangeOperators.EQUAL),
|
||||||
("event_type", RangeOperators.EQUAL),
|
("event_type", RangeOperators.EQUAL),
|
||||||
|
("event_duration_minutes", RangeOperators.EQUAL),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
# we do not want adjacent sessions for the same type and location
|
# we do not want adjacent sessions for the same type and location and duration
|
||||||
ExclusionConstraint(
|
ExclusionConstraint(
|
||||||
name="prevent_adjacent_eventsessions",
|
name="prevent_adjacent_eventsessions",
|
||||||
expressions=[
|
expressions=[
|
||||||
("event_location", RangeOperators.EQUAL),
|
("event_location", RangeOperators.EQUAL),
|
||||||
("event_type", RangeOperators.EQUAL),
|
("event_type", RangeOperators.EQUAL),
|
||||||
|
("event_duration_minutes", RangeOperators.EQUAL),
|
||||||
("when", RangeOperators.ADJACENT_TO),
|
("when", RangeOperators.ADJACENT_TO),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue