# Path: contentious/contrib/basictrans/models.py
# class TranslationContent(ContentItemBase):
#     """ Model for storing simple translations. """
# 
#     class Meta:
#         app_label = "contentious"
#         unique_together = (
#             ('language', 'key'),
#         )
# 
#     language = models.CharField(max_length=7)


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

#BASICTRANS


class BasicTranslationAPI(object):
    """ Implementation of the ContentiousInterface for doing simple translation. """

    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.
        """
        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_for_lang(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):
        language = self._get_lang(template_context)

# Path: contentious/contrib/basictrans/models.py
# class TranslationContent(ContentItemBase):
#     """ Model for storing simple translations. """
# 
#     class Meta:
#         app_label = "contentious"
#         unique_together = (
#             ('language', 'key'),
#         )
# 
#     language = models.CharField(max_length=7)


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

#LIBRARIES

#BASICTRANS


class BasicTranslationAPI(object):
    """ Implementation of the ContentiousInterface for doing simple translation. """

    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.
        """
        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_for_lang(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):
        language = self._get_lang(template_context)

        obj, created = TranslationContent.objects.get_or_create(