def writenextpage(request, parentid, *args, **kwargs): book = request.path.split('/')[-2] if request.user.is_authenticated(): if (not parentid and user.is_staff()) or parentid: form = PageForm return render_to_response("writinganewpage.html", {'form': form, 'parentid': parentid, 'book': book}, context_instance=RequestContext(request)) return goHome()
def submitnewpage(request, parentid, book): if request.user.is_authenticated() and request.method == "POST": if (not parentid and user.is_staff()) or parentid: form = PageForm(request.POST, request.FILES) if form.is_valid(): page = Page() if int(parentid): page.parent = Page.objects.all().get(id=parentid) else: page.parent = None page.author = request.user page.short_desc = form.cleaned_data['short_desc'] if request.FILES.get('video'): page.video = 'https://player.vimeo.com' + (Vimeo_Upload( request.FILES.get('video'))) if request.FILES.get('illustration'): page.illustration = request.FILES.get('illustration') page.video = None page.long_desc = form.cleaned_data['long_desc'] page.book = get_object_or_404(Book, pk=int(book)) page.save() return HttpResponseRedirect("/page:" + str(page.id) + "/") else: return render_to_response( "writinganewpage.html", { 'form': form, 'parentid': parentid, "book": book }, context_instance=RequestContext(request)) return goHome()
def submiteditedpage(request, pageid): if request.user.is_authenticated() and request.method == "POST": page = findPage(pageid) if not page: return go404() if request.user.is_staff or page.author == findUser(request.user): if request.FILES: files = request.FILES elif page.illustration: files = {'illustration': page.illustration} else: files = {} form = PageForm(request.POST, files) if form.is_valid(): page.short_desc = form.cleaned_data['short_desc'] page.illustration = files.get('illustration') page.long_desc = form.cleaned_data['long_desc'] if request.FILES.get('video'): page.video = 'https://player.vimeo.com' + (Vimeo_Upload( request.FILES.get('video'))) page.save() return HttpResponseRedirect("/page:" + str(page.id) + "/") else: return render_to_response( "editingapage.html", { 'form': form, 'page': page }, context_instance=RequestContext(request)) return goHome()
def submiteditedpage(request, pageid): if request.user.is_authenticated() and request.method == "POST": page = findPage(pageid) if not page: return go404() if request.user.is_staff or page.author == findUser(request.user): if request.FILES: files = request.FILES elif page.illustration: files = {'illustration': page.illustration} else: files = {} form = PageForm(request.POST, files) if form.is_valid(): page.short_desc = form.cleaned_data['short_desc'] page.illustration = files.get('illustration') page.long_desc = form.cleaned_data['long_desc'] if request.FILES.get('video'): page.video = 'https://player.vimeo.com' + ( Vimeo_Upload(request.FILES.get('video')) ) page.save() return HttpResponseRedirect("/page:"+str(page.id)+"/") else: return render_to_response("editingapage.html", {'form': form, 'page': page}, context_instance=RequestContext(request)) return goHome()
def submitnewpage(request, parentid, book): if request.user.is_authenticated() and request.method == "POST": if (not parentid and user.is_staff()) or parentid: form = PageForm(request.POST, request.FILES) if form.is_valid(): page = Page() if int(parentid): page.parent = Page.objects.all().get(id=parentid) else: page.parent = None page.author = request.user page.short_desc = form.cleaned_data['short_desc'] if request.FILES.get('video'): page.video = 'https://player.vimeo.com' + ( Vimeo_Upload(request.FILES.get('video')) ) if request.FILES.get('illustration'): page.illustration = request.FILES.get('illustration') page.video = None page.long_desc = form.cleaned_data['long_desc'] page.book = get_object_or_404(Book,pk=int(book)) page.save() return HttpResponseRedirect("/page:"+str(page.id)+"/") else: return render_to_response("writinganewpage.html", {'form': form, 'parentid': parentid, "book": book}, context_instance=RequestContext(request)) return goHome()
def editpage(request, pageid): page = findPage(pageid) if not page: return go404() if request.user.is_staff or page.author == findUser(request.user): already_written = {'short_desc': page.short_desc, 'long_desc': page.long_desc, 'book': page.book} files = {'illustration': page.illustration} form = PageForm(already_written, files) return render_to_response("editingapage.html", {'form': form, 'page': page}, context_instance=RequestContext(request)) return goHome()
def deletebranch(request, pageid): if request.user.is_staff: page = findPage(pageid) if page.parent: parentpage = page.parent page.kill_branch() return HttpResponseRedirect("/page:"+str(parentpage.id)+"/") else: page.kill_branch() return HttpResponseRedirect("/") return goHome()
def deletebranch(request, pageid): if request.user.is_staff: page = findPage(pageid) if page.parent: parentpage = page.parent page.kill_branch() return HttpResponseRedirect("/page:" + str(parentpage.id) + "/") else: page.kill_branch() return HttpResponseRedirect("/") return goHome()
def writenextpage(request, parentid, *args, **kwargs): book = request.path.split('/')[-2] if request.user.is_authenticated(): if (not parentid and user.is_staff()) or parentid: form = PageForm return render_to_response("writinganewpage.html", { 'form': form, 'parentid': parentid, 'book': book }, context_instance=RequestContext(request)) return goHome()
def editpage(request, pageid): page = findPage(pageid) if not page: return go404() if request.user.is_staff or page.author == findUser(request.user): already_written = { 'short_desc': page.short_desc, 'long_desc': page.long_desc, 'book': page.book } files = {'illustration': page.illustration} form = PageForm(already_written, files) return render_to_response("editingapage.html", { 'form': form, 'page': page }, context_instance=RequestContext(request)) return goHome()