# 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

        if self.is_canonical():
            if self.get_translation(request, language):
                return True

        return False

    def get_translation(self, request, language):
        """Returns connected translation for requested language. Returns None
        if the requested language doesn't exist.
        """
        # TODO: Should there a instance be returned even if the instance is a
        # translation?
        if self.is_translation():
            return None
        try:
            translation = self.translations.get(language=language).get_content_object()
            if translation.has_permission(request.user, "view"):
                return translation
            else:
                return None

        except BaseContent.DoesNotExist:
            return None

    def are_comments_allowed(self):
        """Returns true if comments for this instance are allowed. Takes also
        the setup of parent objects into account (if the instance' comments
        setup is set to "default").
        """

# 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


        if self.is_canonical():
            if self.get_translation(request, language):
                return True

        return False

    def get_translation(self, request, language):
        """Returns connected translation for requested language. Returns None
        if the requested language doesn't exist.
        """
        # TODO: Should there a instance be returned even if the instance is a
        # translation?
        if self.is_translation():
            return None
        try:
            translation = self.translations.get(language=language).get_content_object()
            if translation.has_permission(request.user, "view"):
                return translation
            else:
                return None

        except BaseContent.DoesNotExist:
            return None

    def are_comments_allowed(self):
        """Returns true if comments for this instance are allowed. Takes also
        the setup of parent objects into account (if the instance' comments
        setup is set to "default").
        """

        if self.allow_comments == ALLOW_COMMENTS_DEFAULT: