class Page(BasePage): CONTRIBUTOR_AUTHOR = 1 CONTRIBUTOR_PUBLISHER = 2 CONTRIBUTOR_CHOICES = ((CONTRIBUTOR_AUTHOR, _('Author')), (CONTRIBUTOR_PUBLISHER, _('Publisher'))) group = models.ForeignKey(Group, null=True, default=None, on_delete=models.SET_NULL) contributor_type = models.IntegerField(choices=CONTRIBUTOR_CHOICES, default=CONTRIBUTOR_AUTHOR) google_profile = models.URLField(_('Google+ URL'), blank=True) perms = GenericRelation(ObjectPermission, object_id_field="object_id", content_type_field="content_type") objects = PageManager() class Meta: permissions = (("view_page", _("Can view page")), ) app_label = 'pages' def save(self, *args, **kwargs): if not self.group: self.group_id = get_default_group() super(Page, self).save(*args, **kwargs) def get_meta(self, name): """ This method is standard across all models that are related to the Meta model. Used to generate dynamic meta information niche to this model. """ return PageMeta().get_meta(self, name) def get_absolute_url(self): return reverse('page', args=[self.slug]) def get_version_url(self, hash): return reverse('page.version', args=[hash]) @property def has_google_author(self): return self.contributor_type == self.CONTRIBUTOR_AUTHOR @property def has_google_publisher(self): return self.contributor_type == self.CONTRIBUTOR_PUBLISHER
class Page(BasePage): perms = generic.GenericRelation(ObjectPermission, object_id_field="object_id", content_type_field="content_type") objects = PageManager() class Meta: permissions = (("view_page", "Can view page"), ) def get_meta(self, name): """ This method is standard across all models that are related to the Meta model. Used to generate dynamic meta information niche to this model. """ return PageMeta().get_meta(self, name) @models.permalink def get_absolute_url(self): return ("page", [self.slug])
class Page(BasePage): CONTRIBUTOR_AUTHOR = 1 CONTRIBUTOR_PUBLISHER = 2 CONTRIBUTOR_CHOICES = ((CONTRIBUTOR_AUTHOR, _('Author')), (CONTRIBUTOR_PUBLISHER, _('Publisher'))) group = models.ForeignKey(Group, null=True, default=get_default_group) contributor_type = models.IntegerField(choices=CONTRIBUTOR_CHOICES, default=CONTRIBUTOR_AUTHOR) google_profile = models.URLField(_('Google+ URL'), blank=True) perms = generic.GenericRelation(ObjectPermission, object_id_field="object_id", content_type_field="content_type") objects = PageManager() class Meta: permissions = (("view_page", _("Can view page")),) def get_meta(self, name): """ This method is standard across all models that are related to the Meta model. Used to generate dynamic meta information niche to this model. """ return PageMeta().get_meta(self, name) @models.permalink def get_absolute_url(self): return ("page", [self.slug]) @models.permalink def get_version_url(self, hash): return ("page.version", [hash]) @property def has_google_author(self): return self.contributor_type == self.CONTRIBUTOR_AUTHOR @property def has_google_publisher(self): return self.contributor_type == self.CONTRIBUTOR_PUBLISHER