# Path: image_tagging_api/serializers.py
# class TagSerializer(serializers.ModelSerializer):
#     '''
#     Defines fields to be serialized for a Tag
#     '''
# 
#     person_name = serializers.CharField(source='person.name')
# 
#     class Meta:
#         model = Tag
#         fields = ('id', 'image_id', 'person_id', 'person_name',
#                     'x1', 'x2', 'y1', 'y2',
#                     'creation_date', 'last_updated_date')
# 
# Path: message_queue/models.py
# def create_message(queue_name, *args):
#     '''
#     Creates messages and puts them on the queue
#     '''
#     queue = Queue.objects.get(name = queue_name)
# 
#     message = Message(queue = queue)
# 
#     for arg in args:
#         if type(arg) is datetime.datetime:
#             message.date_data = arg
# 
#         elif type(arg) is datetime.date:
#             message.date_data = arg
# 
#         elif type(arg) is float:
#             message.float_data = arg
# 
#         elif type(arg) is int:
#             message.integer_data = arg
# 
#         elif type(arg) is str:
#             message.string_data = arg
# 
#         else:
#             raise ValueError('create_message args not valid')
# 
#     message.save()
# 
#     return message


from django.shortcuts import get_object_or_404
from rest_framework import viewsets
from rest_framework.exceptions import ParseError
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from suggested_image_tagging.models import SuggestedTag
from suggested_image_tagging.serializers import SuggestedTagSerializer
from image_tagging_api.serializers import TagSerializer
from message_queue.models import create_message
from common.utils import intTryParse






class SuggestedTagView(viewsets.GenericViewSet):

    permission_classes = (IsAuthenticated,)
    serializer_class = SuggestedTagSerializer

    def get_queryset(self):

# Path: image_tagging_api/serializers.py
# class TagSerializer(serializers.ModelSerializer):
#     '''
#     Defines fields to be serialized for a Tag
#     '''
# 
#     person_name = serializers.CharField(source='person.name')
# 
#     class Meta:
#         model = Tag
#         fields = ('id', 'image_id', 'person_id', 'person_name',
#                     'x1', 'x2', 'y1', 'y2',
#                     'creation_date', 'last_updated_date')
# 
# Path: message_queue/models.py
# def create_message(queue_name, *args):
#     '''
#     Creates messages and puts them on the queue
#     '''
#     queue = Queue.objects.get(name = queue_name)
# 
#     message = Message(queue = queue)
# 
#     for arg in args:
#         if type(arg) is datetime.datetime:
#             message.date_data = arg
# 
#         elif type(arg) is datetime.date:
#             message.date_data = arg
# 
#         elif type(arg) is float:
#             message.float_data = arg
# 
#         elif type(arg) is int:
#             message.integer_data = arg
# 
#         elif type(arg) is str:
#             message.string_data = arg
# 
#         else:
#             raise ValueError('create_message args not valid')
# 
#     message.save()
# 
#     return message


# Path: suggested_image_tagging/views.py
from django.shortcuts import get_object_or_404
from rest_framework import viewsets
from rest_framework.exceptions import ParseError
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from suggested_image_tagging.models import SuggestedTag
from suggested_image_tagging.serializers import SuggestedTagSerializer
from image_tagging_api.serializers import TagSerializer
from message_queue.models import create_message
from common.utils import intTryParse







class SuggestedTagView(viewsets.GenericViewSet):

    permission_classes = (IsAuthenticated,)
    serializer_class = SuggestedTagSerializer

    def get_queryset(self):

        return SuggestedTag.objects.filter(image__family_id = self.request.user.family_id)