コード例 #1
0
ファイル: views.py プロジェクト: avryhof/devserver
    def get(self, request, *args, **kwargs):
        context = self.get_context_data()

        context['form'] = PlaylistForm()
        context['playlists'] = requests.get(reverse(""))

        return render(request, self.template_name, context)
コード例 #2
0
ファイル: user_progs.py プロジェクト: Interesnij/deputat
 def post(self, request, *args, **kwargs):
     self.list = SoundList.objects.get(uuid=self.kwargs["uuid"])
     self.form = PlaylistForm(request.POST, instance=self.list)
     if request.is_ajax() and self.form.is_valid():
         list = self.form.save(commit=False)
         new_list = list.edit_list(name=list.name,
                                   description=list.description,
                                   order=list.order,
                                   is_public=request.POST.get("is_public"))
         return HttpResponse()
     else:
         return HttpResponseBadRequest()
     return super(UserPlaylistEdit, self).get(request, *args, **kwargs)
コード例 #3
0
ファイル: user_progs.py プロジェクト: Interesnij/deputat
    def post(self, request, *args, **kwargs):
        form_post = PlaylistForm(request.POST)

        if request.is_ajax() and form_post.is_valid():
            new_list = form_post.save(commit=False)
            new_list.creator = request.user
            new_list.save()
            add_playlist(request.POST.get('permalink'), request.user, new_list)
            return render_for_platform(
                request, 'user_music/list.html', {
                    'playlist': new_list,
                    'object_list': new_list.playlist_too(),
                    'user': request.user
                })
        else:
            return HttpResponseBadRequest()
コード例 #4
0
ファイル: user_progs.py プロジェクト: Interesnij/deputat
    def post(self, request, *args, **kwargs):
        form_post = PlaylistForm(request.POST)

        if request.is_ajax() and form_post.is_valid():
            list = form_post.save(commit=False)
            new_list = list.create_list(
                creator=request.user,
                name=list.name,
                description=list.description,
                order=list.order,
                community=None,
                is_public=request.POST.get("is_public"))
            return render_for_platform(request, 'user_music/list/my_list.html',
                                       {
                                           'list': new_list,
                                           'user': request.user
                                       })
        else:
            return HttpResponseBadRequest()
コード例 #5
0
def add_playlist(request):
    form = PlaylistForm(request.POST)

    if form.is_valid():
        title = form.cleaned_data.get("title")
        try:
            existing_playlist = PlayList.objects.get(title=title)
        except PlayList.DoesNotExist:
            try:
                PlayList.objects.create(title=title, user=request.user)
            except Exception:
                resp = dict(result=API_FAILURE)
            else:
                resp = dict(result=API_SUCCESS)
        else:
            resp = dict(result=API_FAILURE)
    else:
        return HttpResponse(status=status.HTTP_400_BAD_REQUEST)

    return Response(resp, status=status.HTTP_200_OK, headers=NO_CACHE_HEADERS)
コード例 #6
0
ファイル: user_progs.py プロジェクト: Interesnij/deputat
 def get_context_data(self, **kwargs):
     context = super(UserSoundcloudSetCreate,
                     self).get_context_data(**kwargs)
     context["form_post"] = PlaylistForm()
     return context