def index(request): if request.method == 'POST': if 'c-video-link' in request.POST: #basic form, create room and redirect to it room_name=getFreeRoom() vid = request.POST['c-video-link'] logging.info('New room link:' + str(vid) + ':'+ str(room_name)) if not isValidVideo(vid): logging.warning('Bad link:' + str(vid) + ':'+ str(room_name)) return render_to_response('create.html',context_instance=RequestContext(request)) r = Room(name=room_name,chat='commune-'+room_name,creation = time(),video = vid,users = 1) r.save() return redirect("/commune/"+room_name+"/") elif 'a-video-link' in request.POST: #advanced form, create room and redirect to it room_name=getFreeRoom() vid = request.POST['a-video-link'] logging.info('New room link:' + str(vid) + ':'+ str(room_name)) if not isValidVideo(vid): logging.warning('Bad link:' + str(vid) + ':'+ str(room_name)) return render_to_response('create.html',context_instance=RequestContext(request)) chat = request.POST['a-channel-name'] r = Room(name=room_name,chat=chat,creation = time(),video = vid,users = 1) r.save() return redirect("/commune/"+room_name+"/") else: #critical error, how did it get to POST processing logging.error('CREATE - Post request without right variables ' + str(request.POST)) raise Http404 return render_to_response('create.html',context_instance=RequestContext(request))
def submit(request): if 'url' in request.GET: #basic form, create room and redirect to it room_name=getFreeRoom() vid = urllib.unquote(request.GET['url']) if not isValidVideo(vid): return render_to_response('badlink.html',{'link':vid},context_instance=RequestContext(request)) r = Room(name=room_name,chat='commune-'+room_name,creation = time(),video = vid,users = 1) r.save() return redirect("/commune/"+room_name+"/") return redirect("/commune/")