# Path: pages/managers/contenttypemanager.py
# class ContentTypeManager(models.Manager):
# 
#     def get_queryset(self):
#         super_ = super(ContentTypeManager, self)
#         qs = super_.get_queryset()
#         if not settings.PAGES_PAGE_USE_EXT_CONTENT_TYPES:
#             return qs.filter(is_extended=False)
#         else:
#             return qs
# 
#     get_query_set = get_queryset
# 
#     def get_queryset_compat(self):
#         get_queryset = (self.get_query_set if hasattr(self, 'get_query_set') else self.get_queryset)
#         return get_queryset()
# 
#     def extended(self):
#         """Return queryset with only extended content types"""
#         return self.get_queryset_compat().filter(is_extended=True)


from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
from pages.managers import ContentTypeManager
"""Implements PageContentType model"""

from __future__ import unicode_literals




def get_all_content_tuple():
    content_types = []
    try:
        types = PageContentType.objects.all()
        for i in types:
            content_types.append((i.type, i.type))
    except Exception:
        # Probably PageContentType table not populated.
        pass
    return tuple(content_types)


@python_2_unicode_compatible
class PageContentType(models.Model):
    type = models.CharField(_('Type'), max_length=100, blank=False)
    class_name = models.CharField(_('Class'), max_length=100, blank=False)
    admin_class_name = models.CharField(_('Admin Class'), max_length=100, blank=False)
    is_extended = models.BooleanField('Extended', default=False)

# Path: pages/managers/contenttypemanager.py
# class ContentTypeManager(models.Manager):
# 
#     def get_queryset(self):
#         super_ = super(ContentTypeManager, self)
#         qs = super_.get_queryset()
#         if not settings.PAGES_PAGE_USE_EXT_CONTENT_TYPES:
#             return qs.filter(is_extended=False)
#         else:
#             return qs
# 
#     get_query_set = get_queryset
# 
#     def get_queryset_compat(self):
#         get_queryset = (self.get_query_set if hasattr(self, 'get_query_set') else self.get_queryset)
#         return get_queryset()
# 
#     def extended(self):
#         """Return queryset with only extended content types"""
#         return self.get_queryset_compat().filter(is_extended=True)


# Path: pages/models/pagecontenttype.py
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
from pages.managers import ContentTypeManager

"""Implements PageContentType model"""

from __future__ import unicode_literals




def get_all_content_tuple():
    content_types = []
    try:
        types = PageContentType.objects.all()
        for i in types:
            content_types.append((i.type, i.type))
    except Exception:
        # Probably PageContentType table not populated.
        pass
    return tuple(content_types)


@python_2_unicode_compatible
class PageContentType(models.Model):
    type = models.CharField(_('Type'), max_length=100, blank=False)
    class_name = models.CharField(_('Class'), max_length=100, blank=False)
    admin_class_name = models.CharField(_('Admin Class'), max_length=100, blank=False)
    is_extended = models.BooleanField('Extended', default=False)

    objects = ContentTypeManager()