Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
on_delete policy
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Turner committed Nov 28, 2016
1 parent 469c3ed commit 9e29247
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
35 changes: 35 additions & 0 deletions icekit_events/migrations/0011_auto_20161128_1049.py
Original file line number Diff line number Diff line change
@@ -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),
),
]
13 changes: 10 additions & 3 deletions icekit_events/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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',
Expand All @@ -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(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion icekit_events/plugins/links/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 9e29247

Please sign in to comment.