Exemple #1
0
    def get(self, request):
        request.session.modified = True

        page = 1
        songs_api = api.songs()
        songs_api = self.set_user_id(request, songs_api)

        form = forms.SongsForm(request.GET)
        if form.is_valid():
            if not form.cleaned_data["search_term"] == "":
                songs_api.set_search_term(
                    form.cleaned_data["search_term"]
                )
            if not form.cleaned_data["search_title"] == "":
                songs_api.set_search_title(
                    form.cleaned_data["search_title"]
                )
            if not form.cleaned_data["search_artist"] == "":
                songs_api.set_search_artist_name(
                    form.cleaned_data["search_artist"]
                )
            if not form.cleaned_data["search_album"] == "":
                songs_api.set_search_album_title(
                    form.cleaned_data["search_album"]
                )

            if not form.cleaned_data["filter_artist_id"] is None:
                songs_api.set_filter_artist_id(
                    form.cleaned_data["filter_artist_id"]
                )
            if not form.cleaned_data["filter_album_id"] is None:
                songs_api.set_filter_album_id(
                    form.cleaned_data["filter_album_id"]
                )
            if not form.cleaned_data["filter_genre"] is None:
                songs_api.set_filter_genre(
                    form.cleaned_data["filter_genre"]
                )
            if not form.cleaned_data["filter_year"] is None:
                songs_api.set_filter_year(
                    form.cleaned_data["filter_year"]
                )

            if (not form.cleaned_data["order_by"] == "" and
                not form.cleaned_data["order_direction"] == ""):
                songs_api.set_order_by(
                    form.cleaned_data["order_by"],
                    form.cleaned_data["order_direction"]
                )
            elif not form.cleaned_data["order_by"] == "":
                songs_api.set_order_by(form.cleaned_data["order_by"])

            if not form.cleaned_data["count"] is None:
                songs_api.set_count(form.cleaned_data["count"])
            if not form.cleaned_data["page"] is None:
                page = form.cleaned_data["page"]

        result = songs_api.index(page)
        result["form"] = form.cleaned_data
        return result
Exemple #2
0
    def get(self, request):
        request.session.modified = True

        songs_api = api.songs()
        songs_api.skipCurrentSong()

        history = api.history()
        current = {}
        current = history.getCurrent()

        return Response(data=current)
Exemple #3
0
    def get(self, request):
        request.session.modified = True

        songs = api.songs()
        current = {"Testing":True}
        try:
            print "Getting next song"
            current = songs.getNextSong()
        except Exception, e:
            print e
            return Response(status=status.HTTP_500_INTERNAL_SERVER_ERROR)
Exemple #4
0
    def get(self, request):
        request.session.modified = True

        songs_api = api.songs()
        songs_api.skipCurrentSong()

        history = api.history()
        current = {}
        current = history.getCurrent()

        return Response(data=current)
Exemple #5
0
    def get(self, request):
        request.session.modified = True

        songs = api.songs()
        current = {"Testing": True}
        try:
            print "Getting next song"
            current = songs.getNextSong()
        except Exception, e:
            print e
            return Response(status=status.HTTP_500_INTERNAL_SERVER_ERROR)
Exemple #6
0
    def get(self, request):
        request.session.modified = True

        page = 1
        songs_api = api.songs()
        songs_api = self.api_set_user_id(request, songs_api)

        form = forms.SongsForm(request.GET)
        if form.is_valid():
            if not form.cleaned_data["search_term"] == "":
                songs_api.set_search_term(form.cleaned_data["search_term"])
            if not form.cleaned_data["search_title"] == "":
                songs_api.set_search_title(form.cleaned_data["search_title"])
            if not form.cleaned_data["search_artist"] == "":
                songs_api.set_search_artist_name(
                    form.cleaned_data["search_artist"])
            if not form.cleaned_data["search_album"] == "":
                songs_api.set_search_album_title(
                    form.cleaned_data["search_album"])

            if not form.cleaned_data["filter_artist_id"] is None:
                songs_api.set_filter_artist_id(
                    form.cleaned_data["filter_artist_id"])
            if not form.cleaned_data["filter_album_id"] is None:
                songs_api.set_filter_album_id(
                    form.cleaned_data["filter_album_id"])
            if not form.cleaned_data["filter_genre"] is None:
                songs_api.set_filter_genre(form.cleaned_data["filter_genre"])
            if not form.cleaned_data["filter_year"] is None:
                songs_api.set_filter_year(form.cleaned_data["filter_year"])

            if (not form.cleaned_data["order_by"] == ""
                    and not form.cleaned_data["order_direction"] == ""):
                songs_api.set_order_by(form.cleaned_data["order_by"],
                                       form.cleaned_data["order_direction"])
            elif not form.cleaned_data["order_by"] == "":
                songs_api.set_order_by(form.cleaned_data["order_by"])

            if not form.cleaned_data["count"] is None:
                songs_api.set_count(form.cleaned_data["count"])
            if not form.cleaned_data["page"] is None:
                page = form.cleaned_data["page"]

        result = songs_api.index(page)
        if request.user.is_authenticated():
            if request.user.groups.filter(
                    name="Default Playlist Managers").exists():
                result["CanManageDefault"] = True
            if not request.user.username == "guest":
                result["CanFave"] = True
        result["form"] = form.cleaned_data
        return Response(data=result)
Exemple #7
0
    def get(self, request):
        request.session.modified = True

        page = 1
        songs_api = api.songs()
        songs_api = self.api_set_user_id(request, songs_api)

        form = forms.SongsForm(request.GET)
        if form.is_valid():
            if not form.cleaned_data["search_term"] == "":
                songs_api.set_search_term(form.cleaned_data["search_term"])
            if not form.cleaned_data["search_title"] == "":
                songs_api.set_search_title(form.cleaned_data["search_title"])
            if not form.cleaned_data["search_artist"] == "":
                songs_api.set_search_artist_name(
                    form.cleaned_data["search_artist"])
            if not form.cleaned_data["search_album"] == "":
                songs_api.set_search_album_title(
                    form.cleaned_data["search_album"])

            if not form.cleaned_data["filter_artist_id"] is None:
                songs_api.set_filter_artist_id(
                    form.cleaned_data["filter_artist_id"])
            if not form.cleaned_data["filter_album_id"] is None:
                songs_api.set_filter_album_id(
                    form.cleaned_data["filter_album_id"])
            if not form.cleaned_data["filter_genre"] is None:
                songs_api.set_filter_genre(form.cleaned_data["filter_genre"])
            if not form.cleaned_data["filter_year"] is None:
                songs_api.set_filter_year(form.cleaned_data["filter_year"])

            if (not form.cleaned_data["order_by"] == ""
                    and not form.cleaned_data["order_direction"] == ""):
                songs_api.set_order_by(form.cleaned_data["order_by"],
                                       form.cleaned_data["order_direction"])
            elif not form.cleaned_data["order_by"] == "":
                songs_api.set_order_by(form.cleaned_data["order_by"])

            if not form.cleaned_data["count"] is None:
                songs_api.set_count(form.cleaned_data["count"])
            if not form.cleaned_data["page"] is None:
                page = form.cleaned_data["page"]

        result = songs_api.index(page)
        result["form"] = form.cleaned_data
        return Response(data=result)
Exemple #8
0
    def get(self, request):
        request.session.modified = True

        songs_api = api.songs()
        songs_api.skipCurrentSong()
Exemple #9
0
    def get(self, request):
        request.session.modified = True

        songs_api = api.songs()
        songs_api.skipCurrentSong()
        return Response("")
Exemple #10
0
    def get(self, request):
        request.session.modified = True

        page = 1
        songs_api = api.songs()
        songs_api = self.api_set_user_id(request, songs_api)

        form = forms.SongsForm(request.GET)
        if form.is_valid():
            if not form.cleaned_data["search_term"] == "":
                songs_api.set_search_term(
                    form.cleaned_data["search_term"]
                )
            if not form.cleaned_data["search_title"] == "":
                songs_api.set_search_title(
                    form.cleaned_data["search_title"]
                )
            if not form.cleaned_data["search_artist"] == "":
                songs_api.set_search_artist_name(
                    form.cleaned_data["search_artist"]
                )
            if not form.cleaned_data["search_album"] == "":
                songs_api.set_search_album_title(
                    form.cleaned_data["search_album"]
                )

            if not form.cleaned_data["filter_artist_id"] is None:
                songs_api.set_filter_artist_id(
                    form.cleaned_data["filter_artist_id"]
                )
            if not form.cleaned_data["filter_album_id"] is None:
                songs_api.set_filter_album_id(
                    form.cleaned_data["filter_album_id"]
                )
            if not form.cleaned_data["filter_genre"] is None:
                songs_api.set_filter_genre(
                    form.cleaned_data["filter_genre"]
                )
            if not form.cleaned_data["filter_year"] is None:
                songs_api.set_filter_year(
                    form.cleaned_data["filter_year"]
                )

            if (not form.cleaned_data["order_by"] == "" and
                not form.cleaned_data["order_direction"] == ""):
                songs_api.set_order_by(
                    form.cleaned_data["order_by"],
                    form.cleaned_data["order_direction"]
                )
            elif not form.cleaned_data["order_by"] == "":
                songs_api.set_order_by(form.cleaned_data["order_by"])

            if not form.cleaned_data["count"] is None:
                songs_api.set_count(form.cleaned_data["count"])
            if not form.cleaned_data["page"] is None:
                page = form.cleaned_data["page"]

        result = songs_api.index(page)
        if request.user.is_authenticated():
            if request.user.groups.filter(name="Default Playlist Managers").exists():
                result["CanManageDefault"] = True
            if not request.user.username == "guest":
                result["CanFave"] = True
        result["form"] = form.cleaned_data
        return Response(
            data=result
        )