# Path: lfc/managers.py
# class BaseContentManager(models.Manager):
#     """Custom manager for BaseContent.
#     """
#     def get_queryset(self):
#         """Overwritten to return BaseContentQuerySet.
#         """
#         return BaseContentQuerySet(self.model)
# 
# Path: lfc/settings.py
# ALLOW_COMMENTS_CHOICES = (
#     (ALLOW_COMMENTS_DEFAULT, _(u"Default")),
#     (ALLOW_COMMENTS_TRUE, _(u"Yes")),
#     (ALLOW_COMMENTS_FALSE, _(u"No")),
# )
# 
# Path: lfc/settings.py
# ALLOW_COMMENTS_DEFAULT = 1
# 
# Path: lfc/settings.py
# ALLOW_COMMENTS_TRUE = 2
# 
# Path: lfc/settings.py
# LANGUAGE_CHOICES = [("0", _(u"Neutral"),)]
# 
# Path: lfc/settings.py
# ORDER_BY_CHOICES = (
#     ("position", _(u"Position ascending")),
#     ("-position", _(u"Position descending")),
#     ("publication_date", _(u"Publication date ascending")),
#     ("-publication_date", _(u"Publication date descending")),
# )
# 
# Path: lfc/settings.py
# IMAGE_SIZES = getattr(settings, 'LFC_IMAGE_SIZES', ((60, 60), (100, 100), (200, 200), (400, 400), (600, 600), (800, 800)))
# 
# Path: lfc/settings.py
# UPLOAD_FOLDER  = getattr(settings, 'LFC_UPLOAD_FOLDER', 'uploads')


import datetime
import re
import workflows.utils
import lfc.utils
from django import template
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.contenttypes import generic
from django.contrib.contenttypes.models import ContentType
from django.core.cache import cache
from django.core.urlresolvers import reverse
from django.db import models
from django.template import RequestContext
from django.template.loader import render_to_string
from django.utils import translation
from django.utils.translation import ugettext_lazy as _
from tagging import fields
from tagging.models import Tag
from tagging.models import TaggedItem
from portlets.models import PortletAssignment
from portlets.models import PortletBlocking
from workflows import WorkflowBase
from workflows.models import Workflow
from workflows.models import State
from workflows.models import StateObjectRelation
from permissions import PermissionBase
from permissions.exceptions import Unauthorized
from permissions.models import Role
from permissions.models import ObjectPermission
from permissions.models import ObjectPermissionInheritanceBlock
from lfc.fields.thumbs import ImageWithThumbsField
from lfc.managers import BaseContentManager
from lfc.settings import ALLOW_COMMENTS_CHOICES
from lfc.settings import ALLOW_COMMENTS_DEFAULT
from lfc.settings import ALLOW_COMMENTS_TRUE
from lfc.settings import LANGUAGE_CHOICES
from lfc.settings import ORDER_BY_CHOICES
from lfc.settings import IMAGE_SIZES
from lfc.settings import UPLOAD_FOLDER
        from lfc.manage.forms import AddForm
            roles = []

        # Check whether the current user is the creator of the current object.
        try:
            if user == self.creator:
                roles.append(Role.objects.get(name="Owner").id)
        except (AttributeError, Role.DoesNotExist):
            pass

        return super(Portal, self).has_permission(user, codename, roles)

    def check_permission(self, user, codename):
        """
        Overwrites django-permissions' check_permission in order to add LFC
        specific groups.
        """
        if not self.has_permission(user, codename):
            raise Unauthorized("'%s' doesn't have permission '%s' for portal." % (user, codename))


class AbstractBaseContent(models.Model, WorkflowBase, PermissionBase):
    """The root of all content types. It provides the inheritable
    BaseContentManager.

    **Attributes:**

    objects
        The default content manager of LFC. Provides a restricted method which
        takes care of the current user's permissions.
    """

# Path: lfc/managers.py
# class BaseContentManager(models.Manager):
#     """Custom manager for BaseContent.
#     """
#     def get_queryset(self):
#         """Overwritten to return BaseContentQuerySet.
#         """
#         return BaseContentQuerySet(self.model)
# 
# Path: lfc/settings.py
# ALLOW_COMMENTS_CHOICES = (
#     (ALLOW_COMMENTS_DEFAULT, _(u"Default")),
#     (ALLOW_COMMENTS_TRUE, _(u"Yes")),
#     (ALLOW_COMMENTS_FALSE, _(u"No")),
# )
# 
# Path: lfc/settings.py
# ALLOW_COMMENTS_DEFAULT = 1
# 
# Path: lfc/settings.py
# ALLOW_COMMENTS_TRUE = 2
# 
# Path: lfc/settings.py
# LANGUAGE_CHOICES = [("0", _(u"Neutral"),)]
# 
# Path: lfc/settings.py
# ORDER_BY_CHOICES = (
#     ("position", _(u"Position ascending")),
#     ("-position", _(u"Position descending")),
#     ("publication_date", _(u"Publication date ascending")),
#     ("-publication_date", _(u"Publication date descending")),
# )
# 
# Path: lfc/settings.py
# IMAGE_SIZES = getattr(settings, 'LFC_IMAGE_SIZES', ((60, 60), (100, 100), (200, 200), (400, 400), (600, 600), (800, 800)))
# 
# Path: lfc/settings.py
# UPLOAD_FOLDER  = getattr(settings, 'LFC_UPLOAD_FOLDER', 'uploads')


# Path: lfc/models.py
import datetime
import re
import workflows.utils
import lfc.utils
from django import template
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.contenttypes import generic
from django.contrib.contenttypes.models import ContentType
from django.core.cache import cache
from django.core.urlresolvers import reverse
from django.db import models
from django.template import RequestContext
from django.template.loader import render_to_string
from django.utils import translation
from django.utils.translation import ugettext_lazy as _
from tagging import fields
from tagging.models import Tag
from tagging.models import TaggedItem
from portlets.models import PortletAssignment
from portlets.models import PortletBlocking
from workflows import WorkflowBase
from workflows.models import Workflow
from workflows.models import State
from workflows.models import StateObjectRelation
from permissions import PermissionBase
from permissions.exceptions import Unauthorized
from permissions.models import Role
from permissions.models import ObjectPermission
from permissions.models import ObjectPermissionInheritanceBlock
from lfc.fields.thumbs import ImageWithThumbsField
from lfc.managers import BaseContentManager
from lfc.settings import ALLOW_COMMENTS_CHOICES
from lfc.settings import ALLOW_COMMENTS_DEFAULT
from lfc.settings import ALLOW_COMMENTS_TRUE
from lfc.settings import LANGUAGE_CHOICES
from lfc.settings import ORDER_BY_CHOICES
from lfc.settings import IMAGE_SIZES
from lfc.settings import UPLOAD_FOLDER
        from lfc.manage.forms import AddForm

            roles = []

        # Check whether the current user is the creator of the current object.
        try:
            if user == self.creator:
                roles.append(Role.objects.get(name="Owner").id)
        except (AttributeError, Role.DoesNotExist):
            pass

        return super(Portal, self).has_permission(user, codename, roles)

    def check_permission(self, user, codename):
        """
        Overwrites django-permissions' check_permission in order to add LFC
        specific groups.
        """
        if not self.has_permission(user, codename):
            raise Unauthorized("'%s' doesn't have permission '%s' for portal." % (user, codename))


class AbstractBaseContent(models.Model, WorkflowBase, PermissionBase):
    """The root of all content types. It provides the inheritable
    BaseContentManager.

    **Attributes:**

    objects
        The default content manager of LFC. Provides a restricted method which
        takes care of the current user's permissions.
    """

    objects = BaseContentManager()