Ejemplo n.º 1
0
def IntentView(request, id='0'):
    """
    Single intent
    """
    if not hal.validate_version(request.META.get('HTTP_ACCEPT')):
        return Response('Invalid version requested',
                        status=status.HTTP_406_NOT_ACCEPTABLE)

    root_url = hal.get_abs_url_for_iwc(
        request
    )  # flake8: noqa TODO: Is Necessary? - Variable not being used in method
    profile = model_access.get_profile(
        request.user.username
    )  # flake8: noqa TODO: Is Necessary? - Variable not being used in method

    queryset = intent_model_access.get_intent_by_id(id)
    if not queryset:
        return Response(status=status.HTTP_404_NOT_FOUND)
    serializer = intent_serializers.IntentSerializer(
        queryset, context={'request': request})
    data = serializer.data
    data = hal.add_hal_structure(
        data, request, hal.generate_content_type(request.accepted_media_type))

    return Response(data)
Ejemplo n.º 2
0
    def retrieve(self, request, pk):
        if not hal.validate_version(request.META.get('HTTP_ACCEPT')):
            return Response('Invalid version requested', status=status.HTTP_406_NOT_ACCEPTABLE)

        root_url = hal.get_abs_url_for_iwc(request)  # flake8: noqa TODO: Is Necessary? - Variable not being used in method
        profile = model_access.get_profile(request.user.username)  # flake8: noqa TODO: Is Necessary? - Variable not being used in method

        queryset = intent_model_access.get_intent_by_id(pk)
        if not queryset:
            return Response(status=status.HTTP_404_NOT_FOUND)
        serializer = intent_serializers.IntentSerializer(queryset,
                context={'request': request})
        data = serializer.data
        data = hal.add_hal_structure(data, request,
            hal.generate_content_type(request.accepted_media_type))

        return Response(data)
Ejemplo n.º 3
0
def IntentView(request, id='0'):
    """
    Single intent
    """
    if not hal.validate_version(request.META.get('HTTP_ACCEPT')):
        return Response('Invalid version requested',
            status=status.HTTP_406_NOT_ACCEPTABLE)

    root_url = hal.get_abs_url_for_iwc(request)
    profile = model_access.get_profile(request.user.username)

    queryset = intent_model_access.get_intent_by_id(id)
    if not queryset:
        return Response(status=status.HTTP_404_NOT_FOUND)
    serializer = intent_serializers.IntentSerializer(queryset,
            context={'request': request})
    data = serializer.data
    data = hal.add_hal_structure(data, request,
        hal.generate_content_type(request.accepted_media_type))

    return Response(data)
Ejemplo n.º 4
0
 def test__get_intent_by_id__not_found_raises_error(self):
     with self.assertRaises(Intent.DoesNotExist):
         model_access.get_intent_by_id(0, True)
Ejemplo n.º 5
0
    def test__get_intent_by_id__not_found(self):
        result = model_access.get_intent_by_id(0)

        self.assertIsNone(result)
Ejemplo n.º 6
0
 def test_get_intent_by_non_existent_id(self):
     intent = model_access.get_intent_by_id(0)
     self.assertIsNone(intent)
Ejemplo n.º 7
0
 def test_get_intent_by_non_existent_id(self):
     intent = model_access.get_intent_by_id(0)
     self.assertIsNone(intent)