Beispiel #1
0
    def delete(self, request, song_id):
        request.session.modified = True

        favourites_api = api.defaultfavourites()

        try:
            return Response(data=favourites_api.remove(song_id))
        except ObjectDoesNotExist:
            return Response(status=status.HTTP_404_NOT_FOUND)
        except Exception, e:
            print e
            return Response(status=status.HTTP_500_INTERNAL_SERVER_ERROR)
Beispiel #2
0
    def delete(self, request, song_id):
        request.session.modified = True

        favourites_api = api.defaultfavourites()

        try:
            return Response(
                data=favourites_api.remove(song_id)
            )
        except ObjectDoesNotExist:
            return Response(status=status.HTTP_404_NOT_FOUND)
        except Exception, e:
            print e
            return Response(status=status.HTTP_500_INTERNAL_SERVER_ERROR)
Beispiel #3
0
    def post(self, request):
        request.session.modified = True

        favourites_api = api.defaultfavourites()

        try:
            song_id = favourites_api.add(self.request.POST["id"])
            return Response(status=status.HTTP_201_CREATED,
                            data={
                                'id': int(self.request.POST['id']),
                            },
                            headers={
                                "Location":
                                reverse("jukebox_api_favourites_item",
                                        kwargs={"song_id": song_id})
                            })
        except ObjectDoesNotExist:
            return Response(status=status.HTTP_404_NOT_FOUND)
        except Exception, e:
            print e
            return Response(status=status.HTTP_500_INTERNAL_SERVER_ERROR)
Beispiel #4
0
    def post(self, request):
        request.session.modified = True

        favourites_api = api.defaultfavourites()

        try:
            song_id = favourites_api.add(self.request.POST["id"])
            return Response(
                status=status.HTTP_201_CREATED,
                data={
                    'id': int(self.request.POST['id']),
                },
                headers={"Location": reverse(
                    "jukebox_api_favourites_item",
                    kwargs={"song_id": song_id}
                )}
            )
        except ObjectDoesNotExist:
            return Response(status=status.HTTP_404_NOT_FOUND)
        except Exception, e:
            print e
            return Response(status=status.HTTP_500_INTERNAL_SERVER_ERROR)