Permalink
Browse files

Merge pull request #74 from evildmp/foreignkeys

on_delete for ForeignKeys, and respect Person.active
  • Loading branch information...
2 parents f5f825e + 22e1622 commit 06860c600bdd07b202c802df542b388f8bdccdfb @evildmp committed Mar 24, 2013
@@ -34,10 +34,12 @@ class Meta:
in_lists = models.BooleanField(_(u"Display in lists"), default=True, db_index=True,
help_text=_(u"If deselected, this item will not appear in lists"))
body = PlaceholderField('body', help_text="Not used or required for external items")
- image = FilerImageField(null=True, blank=True)
+ image = FilerImageField(on_delete=models.SET_NULL, null=True, blank=True)
# universal plugin fields
- hosted_by = models.ForeignKey(Entity, default=Entity.objects.default_entity_id(),
+ hosted_by = models.ForeignKey(Entity,
+ on_delete=models.SET_DEFAULT,
+ default=Entity.objects.default_entity_id(),
related_name='%(class)s_hosted_events', null=True, blank=True,
help_text=u"The entity responsible for publishing this item")
publish_to = models.ManyToManyField(
@@ -112,7 +114,9 @@ def is_uninformative(self):
class ArkestraGenericPluginOptions(models.Model):
class Meta:
abstract = True
- entity = models.ForeignKey(Entity, null=True, blank=True,
+ entity = models.ForeignKey(Entity,
+ on_delete=models.SET_NULL,
+ null=True, blank=True,
help_text="Leave blank for autoselect",
related_name="%(class)s_plugin")
LAYOUTS = (
@@ -10,7 +10,10 @@ class Meta:
# url fields
url = models.URLField(null=True, blank=True, verify_exists=True,
help_text=u"To be used <strong>only</strong> for external items. Use with caution!")
- external_url = models.ForeignKey(ExternalLink, related_name="%(class)s_item", blank=True, null=True,
+ external_url = models.ForeignKey(ExternalLink,
+ related_name="%(class)s_item",
+ on_delete=models.PROTECT,
+ blank=True, null=True,
help_text=u"Select an item from the External Links database."
)
slug = models.SlugField(unique=True, max_length=60, blank=True, help_text=u"Do not meddle with this unless you know exactly what you're doing!", error_messages={"unique": "unique"})
@@ -31,62 +31,3 @@ class Insert(models.Model):
def __unicode__(self):
return self.insertion_point
-
-# from contacts_and_people.models import Entity #, Person, default_entity_id
-# from contacts_and_people.templatetags.entity_tags import work_out_entity
-
-#
-# class ArkestraGenericModel(models.Model):
-# class Meta:
-# abstract = True
-#
-# # core fields
-# title = models.CharField(max_length=255,
-# help_text="e.g. Outrage as man bites dog in unprovoked attack")
-# short_title = models.CharField(max_length=255, null=True, blank=True,
-# help_text= u"e.g. Man bites dog (if left blank, will be copied from Title)")
-# summary = models.TextField(verbose_name="Summary",
-# null=False, blank=False,
-# help_text="e.g. Cardiff man arrested in latest wave of man-on-dog violence (maximum two lines)",)
-# body = PlaceholderField('body', help_text="Not used or required for external items")
-# image = FilerImageField(null=True, blank=True)
-#
-# # universal plugin fields
-# hosted_by = models.ForeignKey(Entity, default=default_entity_id,
-# related_name='%(class)s_hosted_events', null=True, blank=True,
-# help_text=u"The entity responsible for publishing this item")
-# publish_to = models.ManyToManyField(Entity, null=True, blank=True, related_name="%(class)s_publish_to",
-# help_text=u"Use these sensibly - don't send minor items to the home page, for example")
-# please_contact = models.ManyToManyField(Person, related_name='%(class)s_person',
-# help_text=u'The person to whom enquiries about this should be directed ',
-# null=True, blank=True)
-# IMPORTANCES = (
-# (0, u"Normal"),
-# (1, u"More important"),
-# (10, u"Most important"),
-# )
-# importance = models.PositiveIntegerField(null=True, blank=False,
-# default=0, choices=IMPORTANCES,
-# help_text=u"Important items will be featured in lists")
-#
-# def get_importance(self):
-# if self.importance: # if they are not being gathered together, mark them as important
-# return "important"
-# else:
-# return ""
-#
-# @property
-# def links(self):
-# return self.object_links_set.all()
-#
-# @property
-# def external_url(self):
-# # if the inheriting model doesn't have an external_url attribute, we'll give it a None one just in case this is needed
-# return None
-#
-# @property
-# def is_uninformative(self):
-# if self.external_url or self.body.cmsplugin_set.all() or self.please_contact.all() or self.links:
-# return False
-# else:
-# return True
Oops, something went wrong.

0 comments on commit 06860c6

Please sign in to comment.