PageMeta._url_cache.clear() # FIXME: We must clean the page cache, but this cleans it for every sites! cache.clear() return super(PageTree, self).save(*args, **kwargs) def get_site(self): """ used e.g. for self.get_absolute_uri() and the admin page """ return self.site def __unicode__(self): return u"PageTree %r (id: %i, site: %s, type: %s)" % ( self.slug, self.id, self.site.domain, self.TYPE_DICT.get(self.page_type) ) class Meta: app_label = 'pylucid' verbose_name_plural = verbose_name = "PageTree" unique_together = (("site", "slug", "parent"),) # FIXME: It would be great if we can order by get_absolute_url() # ordering = ("site", "id", "position") ordering = ("-lastupdatetime",) # Check Meta.unique_together manually model_utils.auto_add_check_unique_together(PageTree)
_URL_RESOLVER_CACHE.clear() # FIXME: We must only update the cache for the current SITE not for all sites. try: cache.smooth_update( ) # Save "last change" timestamp in django-tools SmoothCacheBackend except AttributeError: # No SmoothCacheBackend used -> clean the complete cache cache.clear() return super(PluginPage, self).save(*args, **kwargs) def __unicode__(self): return u"PluginPage '%s' (pagetree: %r)" % (self.app_label, self.pagetree) class Meta: app_label = 'pylucid' verbose_name_plural = verbose_name = "PluginPage" ordering = ("-lastupdatetime", ) # ordering = ("pagetree", "language") # Check Meta.unique_together manually model_utils.auto_add_check_unique_together(PluginPage) post_save.connect(update_plugin_urls, sender=PluginPage) post_delete.connect(update_plugin_urls, sender=PluginPage)
def get_site(self): """ used e.g. for self.get_absolute_uri() and the admin page """ return self.pagetree.site get_site.short_description = _('on site') get_site.allow_tags = False def get_other_languages(self): return PageMeta.objects.all().filter(pagetree=self.pagetree).exclude(language=self.language) def get_title(self): """ The page title is optional, if not exist, used the slug from the page tree """ return self.title or self.get_name() def get_name(self): return self.name or self.pagetree.slug def __unicode__(self): return u"PageMeta for page: %r (lang: %s, site: %s)" % ( self.pagetree.slug, self.language.code, self.get_site().domain ) class Meta: app_label = 'pylucid' verbose_name_plural = verbose_name = "PageMeta" unique_together = (("pagetree", "language"),) ordering = ("-lastupdatetime",) # ordering = ("pagetree", "language") # Check Meta.unique_together manually model_utils.auto_add_check_unique_together(PageMeta)
def save(self, *args, **kwargs): if not self.pagetree.page_type == self.pagetree.PLUGIN_TYPE: # FIXME: Better error with django model validation? raise AssertionError("Plugin can only exist on a plugin type tree entry!") _URL_RESOLVER_CACHE.clear() # FIXME: We must only update the cache for the current SITE not for all sites. try: cache.smooth_update() # Save "last change" timestamp in django-tools SmoothCacheBackend except AttributeError: # No SmoothCacheBackend used -> clean the complete cache cache.clear() return super(PluginPage, self).save(*args, **kwargs) def __unicode__(self): return u"PluginPage '%s' (pagetree: %r)" % (self.app_label, self.pagetree) class Meta: app_label = 'pylucid' verbose_name_plural = verbose_name = "PluginPage" ordering = ("-lastupdatetime",) # ordering = ("pagetree", "language") # Check Meta.unique_together manually model_utils.auto_add_check_unique_together(PluginPage) post_save.connect(update_plugin_urls, sender=PluginPage) post_delete.connect(update_plugin_urls, sender=PluginPage)
def save(self, *args, **kwargs): if self.pagemeta.pagetree.page_type != self.pagemeta.pagetree.PAGE_TYPE: # TODO: move to django model validation raise AssertionError( "PageContent can only exist on a page type tree entry!") try: cache.smooth_update( ) # Save "last change" timestamp in django-tools SmoothCacheBackend except AttributeError: # No SmoothCacheBackend used -> clean the complete cache cache.clear() return super(PageContent, self).save(*args, **kwargs) def __unicode__(self): return u"PageContent %r (lang: %s, site: %s)" % ( self.pagemeta.pagetree.slug, self.pagemeta.language.code, self.get_site().domain) class Meta: app_label = 'pylucid' verbose_name_plural = verbose_name = "PageContent" ordering = ("-lastupdatetime", ) # ordering = ("pagetree", "language") # Check Meta.unique_together manually model_utils.auto_add_check_unique_together(PageContent)
def get_name(self): """ Page name is optional, return PageTree slug if page name not exist """ return self.pagemeta.name or self.pagemeta.pagetree.slug def get_title(self): """ The page title is optional, if not exist, used the slug from the page tree """ return self.pagemeta.title or self.pagemeta.pagetree.slug def save(self, *args, **kwargs): if self.pagemeta.pagetree.page_type != self.pagemeta.pagetree.PAGE_TYPE: # FIXME: Better error with django model validation? raise AssertionError("PageContent can only exist on a page type tree entry!") cache.clear() # FIXME: This cleaned the complete cache for every site! return super(PageContent, self).save(*args, **kwargs) def __unicode__(self): return u"PageContent %r (lang: %s, site: %s)" % ( self.pagemeta.pagetree.slug, self.pagemeta.language.code, self.get_site().domain ) class Meta: app_label = 'pylucid' verbose_name_plural = verbose_name = "PageContent" ordering = ("-lastupdatetime",) # ordering = ("pagetree", "language") # Check Meta.unique_together manually model_utils.auto_add_check_unique_together(PageContent)
except AttributeError: # No SmoothCacheBackend used -> clean the complete cache cache.clear() return super(PageTree, self).save(*args, **kwargs) def get_site(self): """ used e.g. for self.get_absolute_uri() and the admin page """ return self.site def __unicode__(self): return u"PageTree %r (id: %i, site: %s, type: %s)" % ( self.slug, self.id, self.site.domain, self.TYPE_DICT.get(self.page_type)) class Meta: app_label = 'pylucid' verbose_name_plural = verbose_name = "PageTree" unique_together = (("site", "slug", "parent"), ) # FIXME: It would be great if we can order by get_absolute_url() # ordering = ("site", "id", "position") ordering = ("-lastupdatetime", ) # Check Meta.unique_together manually model_utils.auto_add_check_unique_together(PageTree) post_save.connect(update_plugin_urls, sender=PageTree) post_delete.connect(update_plugin_urls, sender=PageTree)