# Path: contentious/contrib/basicedit/models.py
# class ContentItem(ContentItemBase):
#     """ Model for storing content items. """
#     pass
# 
# Path: contentious/contrib/basicedit/utils.py
# def content_dict_cache_key():
#     prefix = getattr(settings, "CONTENT_CACHE_PREFIX", "")
#     return "%scontent_dict_cache" % prefix
# 
# def get_cache_timeout():
#     return getattr(settings, "CONTENT_CACHE_TIMEOUT", None)


from django.core.cache import cache
from contentious.contrib.basicedit.models import ContentItem
from contentious.contrib.basicedit.utils import (
    content_dict_cache_key,
    get_cache_timeout,
)
#LIBRARIES

#BASICEDIT


class BasicEditAPI(object):
    """ Implementation of the ContentiousInterface for doing simple editing. """

    def in_edit_mode(self, context):
        """ Are we in edit mode?  At the moment we're assuming that all admin
            users are always in edit mode.  You might want to override this method.
        """
        return True
        try:
            user = context['request'].user
            return user.is_admin
        except (KeyError, AttributeError):
            return False

    def get_content_data(self, key, template_context):
        content_dict = self._get_content_dict(template_context) #that's a dict of dicts
        try:
            return content_dict[key]
        except KeyError:
            return {}

    def save_content_data(self, key, data, template_context):

# Path: contentious/contrib/basicedit/models.py
# class ContentItem(ContentItemBase):
#     """ Model for storing content items. """
#     pass
# 
# Path: contentious/contrib/basicedit/utils.py
# def content_dict_cache_key():
#     prefix = getattr(settings, "CONTENT_CACHE_PREFIX", "")
#     return "%scontent_dict_cache" % prefix
# 
# def get_cache_timeout():
#     return getattr(settings, "CONTENT_CACHE_TIMEOUT", None)


# Path: contentious/contrib/basicedit/api.py
from django.core.cache import cache
from contentious.contrib.basicedit.models import ContentItem
from contentious.contrib.basicedit.utils import (
    content_dict_cache_key,
    get_cache_timeout,
)

#LIBRARIES

#BASICEDIT


class BasicEditAPI(object):
    """ Implementation of the ContentiousInterface for doing simple editing. """

    def in_edit_mode(self, context):
        """ Are we in edit mode?  At the moment we're assuming that all admin
            users are always in edit mode.  You might want to override this method.
        """
        return True
        try:
            user = context['request'].user
            return user.is_admin
        except (KeyError, AttributeError):
            return False

    def get_content_data(self, key, template_context):
        content_dict = self._get_content_dict(template_context) #that's a dict of dicts
        try:
            return content_dict[key]
        except KeyError:
            return {}

    def save_content_data(self, key, data, template_context):

        obj, created = ContentItem.objects.get_or_create(