# Path: assessment/serializers.py
# class AnswerSerializer(serializers.ModelSerializer):
#     _uid = serializers.UUIDField(label='ID', read_only=True)
# 
#     class Meta:
#         model = Answer
#         fields = (
#             '_uid',
#             'result',
#             'question',
#             'answer',
#         )
# 
#     def validate(self, attrs):
#         instance = Answer(**attrs)
#         instance.clean()
#         return attrs
# 
#     def validate_result(self, result):
#         try:
#             user = self.context.get('request').user
#         except Exception:
#             raise serializers.ValidationError('Could not access request.user')
# 
#         if not result.user == user:
#             raise serializers.ValidationError('result does not belong to current user!')
#         else:
#             return result
# 
# Path: assessment/models.py
# class Answer(models.Model):
#     _uid = models.UUIDField(
#         primary_key=True,
#         editable=False,
#         default=uuid.uuid4,
#     )
# 
#     result = models.ForeignKey(
#         Result,
#         related_name='answers',
#         verbose_name=_("result"),
#         on_delete=models.CASCADE,
#     )
# 
#     question = models.ForeignKey(
#         Question,
#         related_name='answers',
#         verbose_name=_("question"),
#         on_delete=models.CASCADE,
#     )
# 
#     answer = models.TextField(
#         _("answer"),
#     )
# 
#     class Meta:
#         app_label = 'assessment'
#         unique_together = ('result', 'question')
#         verbose_name = _('answer')
#         verbose_name_plural = _('answers')
# 
#     def __str__(self):
#         return self.answer
# 
#     def clean(self, *args, **kwargs):
#         if self.question not in self.result.survey.questions.all():
#             raise ValidationError("User attempted to answer a question not part of this survey!")


import logging
from rest_framework import status
from rest_framework.decorators import api_view
from rest_framework.response import Response
from assessment.serializers import AnswerSerializer
from assessment.models import Answer
        return Response(response_data, status=status.HTTP_200_OK)


@api_view(['GET', ])
def list_answers(request):
    """
    """
    if request.method == 'GET':
        response_data = {"details": "not implemented"}
        return Response(response_data, status=status.HTTP_200_OK)


@api_view(['GET', ])
def filter_answers(request):
    """
    """
    if request.method == 'GET':
        response_data = {"details": "not implemented"}
        return Response(response_data, status=status.HTTP_200_OK)


@api_view(['DELETE', ])
def delete_answer(request, uuid):
    """
    delete a single answer if the request is from the answer owner
    """

    if request.user.is_authenticated:
        try:
            answer = Answer.objects.get(pk=uuid, admin=request.user)

# Path: assessment/serializers.py
# class AnswerSerializer(serializers.ModelSerializer):
#     _uid = serializers.UUIDField(label='ID', read_only=True)
# 
#     class Meta:
#         model = Answer
#         fields = (
#             '_uid',
#             'result',
#             'question',
#             'answer',
#         )
# 
#     def validate(self, attrs):
#         instance = Answer(**attrs)
#         instance.clean()
#         return attrs
# 
#     def validate_result(self, result):
#         try:
#             user = self.context.get('request').user
#         except Exception:
#             raise serializers.ValidationError('Could not access request.user')
# 
#         if not result.user == user:
#             raise serializers.ValidationError('result does not belong to current user!')
#         else:
#             return result
# 
# Path: assessment/models.py
# class Answer(models.Model):
#     _uid = models.UUIDField(
#         primary_key=True,
#         editable=False,
#         default=uuid.uuid4,
#     )
# 
#     result = models.ForeignKey(
#         Result,
#         related_name='answers',
#         verbose_name=_("result"),
#         on_delete=models.CASCADE,
#     )
# 
#     question = models.ForeignKey(
#         Question,
#         related_name='answers',
#         verbose_name=_("question"),
#         on_delete=models.CASCADE,
#     )
# 
#     answer = models.TextField(
#         _("answer"),
#     )
# 
#     class Meta:
#         app_label = 'assessment'
#         unique_together = ('result', 'question')
#         verbose_name = _('answer')
#         verbose_name_plural = _('answers')
# 
#     def __str__(self):
#         return self.answer
# 
#     def clean(self, *args, **kwargs):
#         if self.question not in self.result.survey.questions.all():
#             raise ValidationError("User attempted to answer a question not part of this survey!")


# Path: assessment/views/api/answer.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 AnswerSerializer
from assessment.models import Answer

        return Response(response_data, status=status.HTTP_200_OK)


@api_view(['GET', ])
def list_answers(request):
    """
    """
    if request.method == 'GET':
        response_data = {"details": "not implemented"}
        return Response(response_data, status=status.HTTP_200_OK)


@api_view(['GET', ])
def filter_answers(request):
    """
    """
    if request.method == 'GET':
        response_data = {"details": "not implemented"}
        return Response(response_data, status=status.HTTP_200_OK)


@api_view(['DELETE', ])
def delete_answer(request, uuid):
    """
    delete a single answer if the request is from the answer owner
    """

    if request.user.is_authenticated:
        try:
            answer = Answer.objects.get(pk=uuid, admin=request.user)

        except (Answer.DoesNotExist, ValueError):