diff --git a/src/program/migrations/0095_event_duration_not_null_eventuuid_unique_proposal_duration_desc_and_new_eventsession_constraint.py b/src/program/migrations/0095_event_duration_not_null_eventuuid_unique_proposal_duration_desc_and_new_eventsession_constraint.py new file mode 100644 index 00000000..7c76132e --- /dev/null +++ b/src/program/migrations/0095_event_duration_not_null_eventuuid_unique_proposal_duration_desc_and_new_eventsession_constraint.py @@ -0,0 +1,54 @@ +# Generated by Django 3.0.3 on 2020-06-21 23:56 + +import uuid + +import django.contrib.postgres.constraints +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("program", "0094_tags_blank"), + ] + + operations = [ + migrations.AlterField( + model_name="event", + name="duration_minutes", + field=models.PositiveIntegerField( + blank=True, + default=None, + help_text="The duration of this event in minutes. Leave blank to use the default from the event_type.", + ), + ), + migrations.AlterField( + model_name="event", + name="uuid", + field=models.UUIDField( + default=uuid.uuid4, + editable=False, + help_text="This field is not the PK of the model. It is used to create EventSlot UUID for FRAB and iCal and other calendaring purposes.", + unique=True, + ), + ), + migrations.AlterField( + model_name="eventproposal", + name="duration", + field=models.IntegerField( + blank=True, + help_text="How much time (in minutes) should we set aside for this event?", + ), + ), + migrations.AddConstraint( + model_name="eventsession", + constraint=django.contrib.postgres.constraints.ExclusionConstraint( + expressions=[ + ("event_location", "="), + ("event_type", "="), + ("when", "-|-"), + ], + name="prevent_adjacent_eventsessions", + ), + ), + ] diff --git a/src/program/models.py b/src/program/models.py index ddda8aba..49984abd 100644 --- a/src/program/models.py +++ b/src/program/models.py @@ -521,7 +521,7 @@ class EventProposal(UserSubmittedModel): duration = models.IntegerField( blank=True, - help_text="How much time (in minutes) should we set aside for this act? Please keep it between 60 and 180 minutes (1-3 hours).", + help_text="How much time (in minutes) should we set aside for this event?", ) submission_notes = models.TextField( @@ -842,6 +842,15 @@ class EventSession(CampRelatedModel): ("event_type", RangeOperators.EQUAL), ], ), + # we do not want adjacent sessions for the same type and location + ExclusionConstraint( + name="prevent_adjacent_eventsessions", + expressions=[ + ("event_location", RangeOperators.EQUAL), + ("event_type", RangeOperators.EQUAL), + ("when", RangeOperators.ADJACENT_TO), + ], + ), ] camp = models.ForeignKey(