diff --git a/icekit_events/migrations/0011_auto_20161128_1049.py b/icekit_events/migrations/0011_auto_20161128_1049.py new file mode 100644 index 0000000..4fa680f --- /dev/null +++ b/icekit_events/migrations/0011_auto_20161128_1049.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('icekit_events', '0010_eventbase_is_drop_in'), + ] + + operations = [ + migrations.AlterField( + model_name='eventbase', + name='derived_from', + field=models.ForeignKey(related_name='derivitives', editable=False, blank=True, to='icekit_events.EventBase', on_delete=django.db.models.deletion.SET_NULL, null=True), + ), + migrations.AlterField( + model_name='eventbase', + name='part_of', + field=models.ForeignKey(related_name='contained_events', help_text=b'If this event is part of another event, select it here.', blank=True, to='icekit_events.EventBase', on_delete=django.db.models.deletion.SET_NULL, null=True), + ), + migrations.AlterField( + model_name='eventbase', + name='primary_type', + field=models.ForeignKey(related_name='events', help_text=b'The primary type of this event: Talk, workshop, etc. Only public Event Types can be primary.', blank=True, to='icekit_events.EventType', on_delete=django.db.models.deletion.SET_NULL, null=True), + ), + migrations.AlterField( + model_name='occurrence', + name='generator', + field=models.ForeignKey(to='icekit_events.EventRepeatsGenerator', blank=True, on_delete=django.db.models.deletion.SET_NULL, null=True), + ), + ] diff --git a/icekit_events/models.py b/icekit_events/models.py index f4203bd..d9c7836 100644 --- a/icekit_events/models.py +++ b/icekit_events/models.py @@ -227,12 +227,13 @@ class EventBase(PolymorphicModel, AbstractBaseModel, PublishingModel, "public Event Types can be primary.", limit_choices_to={'is_public': True}, related_name="events", + on_delete=models.SET_NULL, ) secondary_types = models.ManyToManyField( EventType, blank=True, help_text="Additional/internal types: Education or members events, " "for example.", - related_name="secondary_events", + related_name="secondary_events" ) # use all_types to get the union of primary and secondary types part_of = models.ForeignKey( @@ -241,7 +242,8 @@ class EventBase(PolymorphicModel, AbstractBaseModel, PublishingModel, db_index=True, related_name="contained_events", null=True, - help_text="If this event is part of another event, select it here." + help_text="If this event is part of another event, select it here.", + on_delete=models.SET_NULL ) # access visible contained_events via get_contained_events() derived_from = models.ForeignKey( 'self', @@ -250,6 +252,7 @@ class EventBase(PolymorphicModel, AbstractBaseModel, PublishingModel, editable=False, null=True, related_name='derivitives', + on_delete=models.SET_NULL ) show_in_calendar = models.BooleanField( @@ -562,6 +565,7 @@ class EventRepeatsGenerator(AbstractBaseModel): db_index=True, editable=False, related_name='repeat_generators', + on_delete=models.CASCADE ) recurrence_rule = RecurrenceRuleField( blank=True, @@ -844,10 +848,13 @@ class Occurrence(AbstractBaseModel): db_index=True, editable=False, related_name='occurrences', + on_delete=models.CASCADE ) generator = models.ForeignKey( EventRepeatsGenerator, - blank=True, null=True) + blank=True, null=True, + on_delete=models.SET_NULL + ) start = models.DateTimeField( db_index=True) end = models.DateTimeField( diff --git a/icekit_events/plugins/links/models.py b/icekit_events/plugins/links/models.py index 47c3f50..3be26a3 100644 --- a/icekit_events/plugins/links/models.py +++ b/icekit_events/plugins/links/models.py @@ -3,7 +3,7 @@ class EventLink(AbstractLinkItem): - item = models.ForeignKey("icekit_events.EventBase") + item = models.ForeignKey("icekit_events.EventBase", on_delete=models.CASCADE) class Meta: verbose_name = "Event link"