示例#1
0
def track_add(request):
    if request.method == 'POST':
        form = TrackForm(request.POST)
        if form.is_valid():
            form.save()
            return JsonResponse({'status': 'ok'})
    else:
        form = TrackForm()

    return render(request, 'track_add.html', {'form': form})
示例#2
0
    def post(self, request, *args, **kwargs):
        from music.forms import TrackForm
        form_post = TrackForm(request.POST, request.FILES)

        if request.is_ajax() and form_post.is_valid():
            track = form_post.save(commit=False)
            new_track = track.create_manager_track(
                creator=request.user,
                title=track.title,
                file=track.file,
                lists=request.POST.getlist("list"))
            return render_for_platform(request, 'user_music/new_track.html',
                                       {'object': new_track})
        else:
            return HttpResponseBadRequest()
示例#3
0
    def post(self, request, *args, **kwargs):
        self.track = Music.objects.get(pk=self.kwargs["pk"])
        form_post = TrackForm(request.POST, request.FILES, instance=self.track)

        if request.is_ajax() and form_post.is_valid():
            _track = form_post.save(commit=False)
            new_doc = _track.edit_track(
                title=_track.title,
                file=_track.file,
                lists=request.POST.getlist("list"),
                is_public=request.POST.get("is_public"))
            return render_for_platform(request, 'user_music/new_track.html',
                                       {'object': self.track})
        else:
            return HttpResponseBadRequest()