Esempio n. 1
0
    def get(self, request):
        request.session.modified = True

        page = 1
        history_api = api.history()
        history_api = self.api_set_user_id(request, history_api)

        form = forms.HistoryForm(request.GET)
        if form.is_valid():
            if (not form.cleaned_data["order_by"] == "" and
                not form.cleaned_data["order_direction"] == ""):
                history_api.set_order_by(
                    form.cleaned_data["order_by"],
                    form.cleaned_data["order_direction"]
                )
            elif not form.cleaned_data["order_by"] == "":
                history_api.set_order_by(form.cleaned_data["order_by"])

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

        return Response(
            data=history_api.index(page)
        )
Esempio n. 2
0
    def get(self, request):
        request.session.modified = True

        page = 1
        history_api = api.history()
        history_api = self.api_set_user_id(request, history_api)

        form = forms.HistoryForm(request.GET)
        if form.is_valid():
            if (not form.cleaned_data["order_by"] == "" and
                not form.cleaned_data["order_direction"] == ""):
                history_api.set_order_by(
                    form.cleaned_data["order_by"],
                    form.cleaned_data["order_direction"]
                )
            elif not form.cleaned_data["order_by"] == "":
                history_api.set_order_by(form.cleaned_data["order_by"])

            if not form.cleaned_data["count"] is None:
                history_api.set_count(form.cleaned_data["count"])
            if not form.cleaned_data["page"] is None:
                page = form.cleaned_data["page"]
        response = history_api.index(page)
        if request.user.is_authenticated():
            if request.user.groups.filter(name="Default Playlist Managers").exists():
                response["CanManageDefault"] = True
            if not request.user.username == "guest":
                response["CanFave"] = True

        return Response(
            data=response
        )
Esempio n. 3
0
    def get(self, request):
        request.session.modified = True

        page = 1
        history_api = api.history()
        history_api = self.api_set_user_id(request, history_api)

        form = forms.HistoryForm(request.GET)
        if form.is_valid():
            if (not form.cleaned_data["order_by"] == "" and
                not form.cleaned_data["order_direction"] == ""):
                history_api.set_order_by(
                    form.cleaned_data["order_by"],
                    form.cleaned_data["order_direction"]
                )
            elif not form.cleaned_data["order_by"] == "":
                history_api.set_order_by(form.cleaned_data["order_by"])

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

        return Response(
            data=history_api.index(page)
        )
Esempio n. 4
0
    def get(self, request):
        request.session.modified = True

        page = 1
        history_api = api.history()
        history_api = self.api_set_user_id(request, history_api)

        form = forms.HistoryForm(request.GET)
        if form.is_valid():
            if (not form.cleaned_data["order_by"] == ""
                    and not form.cleaned_data["order_direction"] == ""):
                history_api.set_order_by(form.cleaned_data["order_by"],
                                         form.cleaned_data["order_direction"])
            elif not form.cleaned_data["order_by"] == "":
                history_api.set_order_by(form.cleaned_data["order_by"])

            if not form.cleaned_data["count"] is None:
                history_api.set_count(form.cleaned_data["count"])
            if not form.cleaned_data["page"] is None:
                page = form.cleaned_data["page"]
        response = history_api.index(page)
        if request.user.is_authenticated():
            if request.user.groups.filter(
                    name="Default Playlist Managers").exists():
                response["CanManageDefault"] = True
            if not request.user.username == "guest":
                response["CanFave"] = True

        return Response(data=response)
Esempio n. 5
0
    def get(self, request):
        request.session.modified = True

        history = api.history()
        current = {}
        try:
            current = history.getCurrent()
        except:
            pass

        return Response(data=current)
Esempio n. 6
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)
Esempio n. 7
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)
Esempio n. 8
0
    def get(self, request):
        request.session.modified = True

        history = api.history()
        current = {}
        try:
            current = history.getCurrent()
        except:
            pass

        return Response(
            data=current
        )
Esempio n. 9
0
    def get(self, request):
        request.session.modified = True

        history = api.history()
        return history.getCurrent()