# Path: assessment/serializers.py
# class QuestionSerializer(TranslatableModelSerializer):
#     _uid = serializers.UUIDField(label='ID', read_only=True)
#     translations = TranslatedFieldsField(shared_model=Question)
#     text = serializers.SerializerMethodField()
#     result = serializers.SerializerMethodField(read_only=True)
#     url = serializers.HyperlinkedIdentityField(
#         read_only=True,
#         view_name='assessment-api:retrieve_question',
#         lookup_field='pk',
#         lookup_url_kwarg='uuid',
#     )
# 
#     class Meta:
#         model = Question
#         fields = (
#             '_uid',
#             'survey',
#             'result',
#             'of_type',
#             'translations',
#             'url',
#             'text',
#         )
# 
#     def get_result(self, obj):
#         try:
#             user = self.context.get('request').user
#         except Exception:
#             return None
# 
#         if user.id is None:
#             return None
# 
#         try:
#             result = Result.objects.get(survey=obj.survey, user=user)
#         except Result.DoesNotExist:
#             return None
#         else:
#             return str(result.pk)
# 
#     def get_text(self, obj):
#         try:
#             return obj.question
#         except ObjectDoesNotExist:
#             return _("Translation does not exist for your current language.")
# 
# Path: assessment/models.py
# class Question(TranslatableModel):
#     TRUEFALSE = "tf"
#     MULTIPLE_CHOICE = "mc"
#     TEXT = "txt"
# 
#     QUESTION_TYPE = (
#         (TRUEFALSE, _('true or false')),
#         (MULTIPLE_CHOICE, _('multiple choice')),
#         (TEXT, _('text')),
#     )
# 
#     _uid = models.UUIDField(
#         primary_key=True,
#         editable=False,
#         default=uuid.uuid4,
#     )
# 
#     translations = TranslatedFields(
#         question=models.TextField(_("question")),
#     )
# 
#     survey = models.ForeignKey(
#         Survey,
#         related_name='questions',
#         verbose_name=_("survey"),
#         on_delete=models.CASCADE,
#     )
# 
#     is_required = models.BooleanField(
#         _("required"),
#         default=False,
#     )
# 
#     of_type = models.CharField(
#         _("type"),
#         max_length=3,
#         choices=QUESTION_TYPE,
#         default=TRUEFALSE,
#     )
# 
#     class Meta:
#         app_label = 'assessment'
#         verbose_name = _("question")
#         verbose_name_plural = _("questions")
# 
#     def __str__(self):
#         return self.question


import logging
from rest_framework import status
from rest_framework.decorators import api_view
from rest_framework.response import Response
from assessment.serializers import QuestionSerializer
from assessment.models import Question
# -*- coding: utf-8 -*-


@api_view(['GET', ])
def retrieve_question(request, uuid):
    """
    """
    try:
        question = Question.objects.get(pk=uuid)

# Path: assessment/serializers.py
# class QuestionSerializer(TranslatableModelSerializer):
#     _uid = serializers.UUIDField(label='ID', read_only=True)
#     translations = TranslatedFieldsField(shared_model=Question)
#     text = serializers.SerializerMethodField()
#     result = serializers.SerializerMethodField(read_only=True)
#     url = serializers.HyperlinkedIdentityField(
#         read_only=True,
#         view_name='assessment-api:retrieve_question',
#         lookup_field='pk',
#         lookup_url_kwarg='uuid',
#     )
# 
#     class Meta:
#         model = Question
#         fields = (
#             '_uid',
#             'survey',
#             'result',
#             'of_type',
#             'translations',
#             'url',
#             'text',
#         )
# 
#     def get_result(self, obj):
#         try:
#             user = self.context.get('request').user
#         except Exception:
#             return None
# 
#         if user.id is None:
#             return None
# 
#         try:
#             result = Result.objects.get(survey=obj.survey, user=user)
#         except Result.DoesNotExist:
#             return None
#         else:
#             return str(result.pk)
# 
#     def get_text(self, obj):
#         try:
#             return obj.question
#         except ObjectDoesNotExist:
#             return _("Translation does not exist for your current language.")
# 
# Path: assessment/models.py
# class Question(TranslatableModel):
#     TRUEFALSE = "tf"
#     MULTIPLE_CHOICE = "mc"
#     TEXT = "txt"
# 
#     QUESTION_TYPE = (
#         (TRUEFALSE, _('true or false')),
#         (MULTIPLE_CHOICE, _('multiple choice')),
#         (TEXT, _('text')),
#     )
# 
#     _uid = models.UUIDField(
#         primary_key=True,
#         editable=False,
#         default=uuid.uuid4,
#     )
# 
#     translations = TranslatedFields(
#         question=models.TextField(_("question")),
#     )
# 
#     survey = models.ForeignKey(
#         Survey,
#         related_name='questions',
#         verbose_name=_("survey"),
#         on_delete=models.CASCADE,
#     )
# 
#     is_required = models.BooleanField(
#         _("required"),
#         default=False,
#     )
# 
#     of_type = models.CharField(
#         _("type"),
#         max_length=3,
#         choices=QUESTION_TYPE,
#         default=TRUEFALSE,
#     )
# 
#     class Meta:
#         app_label = 'assessment'
#         verbose_name = _("question")
#         verbose_name_plural = _("questions")
# 
#     def __str__(self):
#         return self.question


# Path: assessment/views/api/question.py
import logging
from rest_framework import status
from rest_framework.decorators import api_view
from rest_framework.response import Response
from assessment.serializers import QuestionSerializer
from assessment.models import Question

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


@api_view(['GET', ])
def retrieve_question(request, uuid):
    """
    """
    try:
        question = Question.objects.get(pk=uuid)

    except (Question.DoesNotExist, ValueError):