# Path: proso_mnemonics/models.py
# class Mnemonic(models.Model):
#     LANGUAGES = [(i, code) for i, (code, name) in enumerate(settings.LANGUAGES)]
#     LANGUAGES_REVERSE = dict((t[1], t[0]) for t in LANGUAGES)
# 
#     place = models.ForeignKey(Place)
#     text = models.TextField()
#     language = models.SmallIntegerField(choices=LANGUAGES, default=LANGUAGES[0][0])
# 
#     def to_serializable(self):
#         return {
#             'code': self.place.code,
#             'text': self.text,
#         }


from geography.utils import JsonResponse
from logging import getLogger
from proso_mnemonics.models import Mnemonic
from django.views.decorators.cache import cache_page
# -*- coding: utf-8 -*-


LOGGER = getLogger(__name__)


@cache_page(60 * 60)
def mnemonics(request):
    lang = Mnemonic.LANGUAGES_REVERSE[request.LANGUAGE_CODE]

# Path: proso_mnemonics/models.py
# class Mnemonic(models.Model):
#     LANGUAGES = [(i, code) for i, (code, name) in enumerate(settings.LANGUAGES)]
#     LANGUAGES_REVERSE = dict((t[1], t[0]) for t in LANGUAGES)
# 
#     place = models.ForeignKey(Place)
#     text = models.TextField()
#     language = models.SmallIntegerField(choices=LANGUAGES, default=LANGUAGES[0][0])
# 
#     def to_serializable(self):
#         return {
#             'code': self.place.code,
#             'text': self.text,
#         }


# Path: proso_mnemonics/views.py
from geography.utils import JsonResponse
from logging import getLogger
from proso_mnemonics.models import Mnemonic
from django.views.decorators.cache import cache_page

# -*- coding: utf-8 -*-


LOGGER = getLogger(__name__)


@cache_page(60 * 60)
def mnemonics(request):
    lang = Mnemonic.LANGUAGES_REVERSE[request.LANGUAGE_CODE]

    mnemonics = Mnemonic.objects.filter(language=lang).select_related('place')