Beispiel #1
0
def looklet_shot_list_update_list(request,
                                  content_format=None,
                                  pk=None,
                                  colorstyle=None,
                                  photodate=None,
                                  reshoot=False,
                                  timestamp=None,
                                  username=None):
    """
    List all looklet_shot_list_updates, or create a new looklet_shot_list_update.
    """

    if request.method == 'GET':
        looklet_shot_list_updates = LookletShotList.objects.all()
        serializer = LookletShotListSerializer(looklet_shot_list_updates, many=True)
        return Response(serializer.data)

    elif request.method == 'POST':
        serializer = LookletShotListSerializer(data=request.data)
        if serializer.is_valid():
            serializer.save()
            return Response(serializer.data, status=status.HTTP_201_CREATED)
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)

    elif request.method == 'PUT':
        if not colorstyle:
            colorstyle = request.data['colorstyle']
        try:
            looklet_shot_list_update = LookletShotList.objects.get(colorstyle=colorstyle)
        except LookletShotList.DoesNotExist:
            return Response(status=status.HTTP_404_NOT_FOUND)
        serializer = LookletShotListSerializer(looklet_shot_list_update,
                                               data=request.data)
        if serializer.is_valid():
            serializer.save()
            return Response(serializer.data)
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Beispiel #2
0
def looklet_shot_list_update_detail(request,
                                    content_format=None,
                                    pk=None,
                                    colorstyle=None,
                                    photodate=None,
                                    reshoot=False,
                                    timestamp=None,
                                    username=None):
    """
    Retrieve, update or delete an LookletShotList instance.
    """
    if not colorstyle:
        colorstyle = request.data['colorstyle']
        #photodate = request.data['photodate']
        pass

    looklet_shot_list_update = ''
    try:
        looklet_shot_list_update = LookletShotList.objects.get(colorstyle=colorstyle)
    except LookletShotList.DoesNotExist:
        pass
        # try:
        #     looklet_shot_list_update = LookletShotList.objects.get(colorstyle=colorstyle)
        # except LookletShotList.DoesNotExist:
        #     return Response(status=status.HTTP_404_NOT_FOUND)

    if request.method == 'GET':
        if not looklet_shot_list_update:
            looklet_shot_list_updates = LookletShotList.objects.all()
        else:
            looklet_shot_list_updates = looklet_shot_list_update
        serializer = LookletShotListSerializer(looklet_shot_list_updates, many=True)
        return Response(serializer.data)

    elif request.method == 'POST':
        serializer = LookletShotListSerializer(data=request.data)
        try:
            looklet_shot_list_update = LookletShotList.objects.get(colorstyle=colorstyle)
            pass
        except LookletShotList.DoesNotExist:
            if serializer.is_valid():
                serializer.save()
                return Response(serializer.data, status=status.HTTP_201_CREATED)
            return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)

    elif request.method == 'PUT':
        if not colorstyle:
            colorstyle = request.data['colorstyle']
        looklet_shot_list_update = LookletShotList.objects.get(colorstyle=colorstyle
                                                               )
        serializer = LookletShotListSerializer(looklet_shot_list_update,
                                               data=request.data)
        if serializer.is_valid():
            serializer.save()
            return Response(serializer.data)
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)

    elif request.method == 'DELETE':
        looklet_shot_list_update = LookletShotList.objects.get(colorstyle=colorstyle)
        looklet_shot_list_update.delete()
        return Response(status=status.HTTP_204_NO_CONTENT)