# Path: pages/models/pagecontenttypes.py
# class PageSlugContent(PageBaseContent):
#     slug = models.CharField(max_length=PAGE_MAX_SLUG_LENGTH)
#     objects = models.Manager()
# 
#     @property
#     def full_slug(self):
#         return self.language + '/' + self.slug
# 
#     def update_fields(self, change):
#         if not change:
#             self.type = 'slug'
# 
#     def save(self, *args, **kwargs):
#         title = self.slug
#         if not len(title):
#             if settings.PAGES_PAGE_USE_META_TITLE_FOR_SLUG:
#                 try:
#                     meta = PageMetaContent.objects.get(page=self.page, language=self.language)
#                     title = meta.title
#                 except PageMetaContent.DoesNotExist:
#                     pass
#             else:
#                 title = self.page.name
#         self.slug = orig = slugify.slugify(title)[:PAGE_MAX_SLUG_LENGTH]
#         for x in itertools.count(1):
#             if not PageSlugContent.objects.exclude(
#                     page=self.page
#             ).filter(slug=self.slug, language=self.language).exists():
#                 break
#             self.slug = '{0:s}-{1:d}'.format(orig[:PAGE_MAX_SLUG_LENGTH - len(str(x)) - 1], x)
#         super(PageSlugContent, self).save(*args, **kwargs)
# 
#     class Meta(PageBaseContent.Meta):
#         app_label = 'pages'
#         verbose_name = _('Slug')
#         verbose_name_plural = _('Slugs')
#         unique_together = ('language', 'page',)
# 
#     class PageMeta(PageBaseContent.PageMeta):
#         context_name = 'slug'
#         multiple_per_page = True
#         multiple_per_locale = False
# 
# Path: pages/models/pagecontenttypes.py
# class PageRedirectContent(PageBaseContent):
#     redirect_to_page = models.CharField(max_length=254, null=True, blank=True)
#     redirect_to_url = models.URLField(max_length=254, null=True, blank=True)
#     is_permanent = models.BooleanField(_('Permanent'), default=False)
# 
#     def update_fields(self, change):
#         if not change:
#             self.type = 'redirect'
# 
#     def get_redirect_url(self, request):
#         url = None
#         if self.redirect_to_page:
#             url = request.build_absolute_uri(self.redirect_to_page)
#         else:
#             if self.redirect_to_url:
#                 url = self.redirect_to_url
#         return url
# 
#     class Meta(PageBaseContent.Meta):
#         app_label = 'pages'
#         verbose_name = _('Redirect')
#         verbose_name_plural = _('Redirect')
# 
#     class PageMeta(PageBaseContent.PageMeta):
#         context_name = 'redirect'
#         multiple_per_page = True
#         multiple_per_locale = False
# 
# Path: pages/models/pagecontenttypes.py
# class PageMetaContent(PageBaseContent):
#     title = models.CharField(max_length=160, blank=True)
#     description = models.TextField(max_length=160, blank=True)
#     keywords = models.CharField(max_length=200, blank=True)
#     is_noindex = models.BooleanField(_('NoIndex'), default=False)
#     is_nofollow = models.BooleanField(_('NoFollow'), default=False)
#     objects = models.Manager()
# 
#     def update_fields(self, change):
#         if not change:
#             self.type = 'meta'
# 
#     @property
#     def robots(self):
#         """Return values for robots html meta key"""
#         r = 'noindex' if self.is_noindex else 'index'
#         r += ','
#         r += 'nofollow' if self.is_nofollow else 'follow'
#         return r
# 
#     class Meta(PageBaseContent.Meta):
#         app_label = 'pages'
#         verbose_name = _('Meta')
#         verbose_name_plural = _('Meta')
#         unique_together = ('language', 'page',)
# 
#     class PageMeta(PageBaseContent.PageMeta):
#         context_name = 'meta'
#         multiple_per_page = True
#         multiple_per_locale = False
# 
# Path: pages/models/pagecontenttypes.py
# class PageTextContent(PageBaseContent):
#     text = models.TextField(blank=True)
#     is_template = models.BooleanField(_('Template?'), default=False)
#     objects = models.Manager()
# 
#     def update_fields(self, change):
#         if not change:
#             self.type = 'text'
# 
#     class Meta(PageBaseContent.Meta):
#         app_label = 'pages'
#         verbose_name = _('Text')
#         verbose_name_plural = _('Text')
# 
#     class PageMeta(PageBaseContent.PageMeta):
#         context_name = 'text'
#         multiple_per_page = True
#         multiple_per_locale = True
# 
# Path: pages/models/pagecontenttypes.py
# class PageMarkdownContent(PageBaseContent):
#     text = MarkupField(blank=True)
#     is_template = models.BooleanField(_('Template?'), default=False)
#     objects = models.Manager()
# 
#     def update_fields(self, change):
#         if not change:
#             self.type = 'markdown'
# 
#     class Meta(PageBaseContent.Meta):
#         app_label = 'pages'
#         verbose_name = _('Markdown')
#         verbose_name_plural = _('Markdown')
# 
#     class PageMeta(PageBaseContent.PageMeta):
#         context_name = 'markdown'
#         multiple_per_page = True
#         multiple_per_locale = True


from django.contrib import admin
from pages.models import PageSlugContent
from pages.models import PageRedirectContent
from pages.models import PageMetaContent
from pages.models import PageTextContent
from pages.models import PageMarkdownContent
"""Implements admin interface for page content"""




class PageSlugContentAdmin(admin.ModelAdmin):
    list_display = ('__str__', 'created_by', 'updated_by', 'date_created', 'date_updated',)
    list_display_links = ['__str__']

    exclude = ('type', 'sid', 'is_extended', 'created_by', 'updated_by',)
    save_on_top = True
    actions_on_bottom = True



# Path: pages/models/pagecontenttypes.py
# class PageSlugContent(PageBaseContent):
#     slug = models.CharField(max_length=PAGE_MAX_SLUG_LENGTH)
#     objects = models.Manager()
# 
#     @property
#     def full_slug(self):
#         return self.language + '/' + self.slug
# 
#     def update_fields(self, change):
#         if not change:
#             self.type = 'slug'
# 
#     def save(self, *args, **kwargs):
#         title = self.slug
#         if not len(title):
#             if settings.PAGES_PAGE_USE_META_TITLE_FOR_SLUG:
#                 try:
#                     meta = PageMetaContent.objects.get(page=self.page, language=self.language)
#                     title = meta.title
#                 except PageMetaContent.DoesNotExist:
#                     pass
#             else:
#                 title = self.page.name
#         self.slug = orig = slugify.slugify(title)[:PAGE_MAX_SLUG_LENGTH]
#         for x in itertools.count(1):
#             if not PageSlugContent.objects.exclude(
#                     page=self.page
#             ).filter(slug=self.slug, language=self.language).exists():
#                 break
#             self.slug = '{0:s}-{1:d}'.format(orig[:PAGE_MAX_SLUG_LENGTH - len(str(x)) - 1], x)
#         super(PageSlugContent, self).save(*args, **kwargs)
# 
#     class Meta(PageBaseContent.Meta):
#         app_label = 'pages'
#         verbose_name = _('Slug')
#         verbose_name_plural = _('Slugs')
#         unique_together = ('language', 'page',)
# 
#     class PageMeta(PageBaseContent.PageMeta):
#         context_name = 'slug'
#         multiple_per_page = True
#         multiple_per_locale = False
# 
# Path: pages/models/pagecontenttypes.py
# class PageRedirectContent(PageBaseContent):
#     redirect_to_page = models.CharField(max_length=254, null=True, blank=True)
#     redirect_to_url = models.URLField(max_length=254, null=True, blank=True)
#     is_permanent = models.BooleanField(_('Permanent'), default=False)
# 
#     def update_fields(self, change):
#         if not change:
#             self.type = 'redirect'
# 
#     def get_redirect_url(self, request):
#         url = None
#         if self.redirect_to_page:
#             url = request.build_absolute_uri(self.redirect_to_page)
#         else:
#             if self.redirect_to_url:
#                 url = self.redirect_to_url
#         return url
# 
#     class Meta(PageBaseContent.Meta):
#         app_label = 'pages'
#         verbose_name = _('Redirect')
#         verbose_name_plural = _('Redirect')
# 
#     class PageMeta(PageBaseContent.PageMeta):
#         context_name = 'redirect'
#         multiple_per_page = True
#         multiple_per_locale = False
# 
# Path: pages/models/pagecontenttypes.py
# class PageMetaContent(PageBaseContent):
#     title = models.CharField(max_length=160, blank=True)
#     description = models.TextField(max_length=160, blank=True)
#     keywords = models.CharField(max_length=200, blank=True)
#     is_noindex = models.BooleanField(_('NoIndex'), default=False)
#     is_nofollow = models.BooleanField(_('NoFollow'), default=False)
#     objects = models.Manager()
# 
#     def update_fields(self, change):
#         if not change:
#             self.type = 'meta'
# 
#     @property
#     def robots(self):
#         """Return values for robots html meta key"""
#         r = 'noindex' if self.is_noindex else 'index'
#         r += ','
#         r += 'nofollow' if self.is_nofollow else 'follow'
#         return r
# 
#     class Meta(PageBaseContent.Meta):
#         app_label = 'pages'
#         verbose_name = _('Meta')
#         verbose_name_plural = _('Meta')
#         unique_together = ('language', 'page',)
# 
#     class PageMeta(PageBaseContent.PageMeta):
#         context_name = 'meta'
#         multiple_per_page = True
#         multiple_per_locale = False
# 
# Path: pages/models/pagecontenttypes.py
# class PageTextContent(PageBaseContent):
#     text = models.TextField(blank=True)
#     is_template = models.BooleanField(_('Template?'), default=False)
#     objects = models.Manager()
# 
#     def update_fields(self, change):
#         if not change:
#             self.type = 'text'
# 
#     class Meta(PageBaseContent.Meta):
#         app_label = 'pages'
#         verbose_name = _('Text')
#         verbose_name_plural = _('Text')
# 
#     class PageMeta(PageBaseContent.PageMeta):
#         context_name = 'text'
#         multiple_per_page = True
#         multiple_per_locale = True
# 
# Path: pages/models/pagecontenttypes.py
# class PageMarkdownContent(PageBaseContent):
#     text = MarkupField(blank=True)
#     is_template = models.BooleanField(_('Template?'), default=False)
#     objects = models.Manager()
# 
#     def update_fields(self, change):
#         if not change:
#             self.type = 'markdown'
# 
#     class Meta(PageBaseContent.Meta):
#         app_label = 'pages'
#         verbose_name = _('Markdown')
#         verbose_name_plural = _('Markdown')
# 
#     class PageMeta(PageBaseContent.PageMeta):
#         context_name = 'markdown'
#         multiple_per_page = True
#         multiple_per_locale = True


# Path: pages/admin/pagecontenttypes.py
from django.contrib import admin
from pages.models import PageSlugContent
from pages.models import PageRedirectContent
from pages.models import PageMetaContent
from pages.models import PageTextContent
from pages.models import PageMarkdownContent

"""Implements admin interface for page content"""




class PageSlugContentAdmin(admin.ModelAdmin):
    list_display = ('__str__', 'created_by', 'updated_by', 'date_created', 'date_updated',)
    list_display_links = ['__str__']

    exclude = ('type', 'sid', 'is_extended', 'created_by', 'updated_by',)
    save_on_top = True
    actions_on_bottom = True



admin.site.register(PageSlugContent, PageSlugContentAdmin)