def insert(request): if request.method == 'POST': # If the form has been submitted... form = VideoMoodForm(request.POST) # A form bound to the POST data if form.is_valid(): # All validation rules pass Utils.insertNewVideo(form.cleaned_data['video_id'],form.cleaned_data['mood_name'], form.cleaned_data['category']) return HttpResponse('thanks ' + form.cleaned_data['video_id'] +' , ' + form.cleaned_data['category'] +' , ' + form.cleaned_data['mood_name']) else: form = VideoMoodForm() # An unbound form return render_to_response('VideoMoodApp/insert.html', { 'form': form}, context_instance=RequestContext(request))
def insert(request): if request.method == 'POST': # If the form has been submitted... form = VideoMoodForm(request.POST) # A form bound to the POST data if form.is_valid(): # All validation rules pass Utils.insertNewVideo(form.cleaned_data['video_id'], form.cleaned_data['mood_name'], form.cleaned_data['category']) return HttpResponse('thanks ' + form.cleaned_data['video_id'] + ' , ' + form.cleaned_data['category'] + ' , ' + form.cleaned_data['mood_name']) else: form = VideoMoodForm() # An unbound form return render_to_response('VideoMoodApp/insert.html', {'form': form}, context_instance=RequestContext(request))
def result(request): query = request.GET.get('query', '') if query: videos = [x.video_id for x in Utils.getVideosFromMood(query)] if not videos: return HttpResponse("No results for this query") else: #json_list = simplejson.dumps(videos) return render_to_response('VideoMoodApp/result.html', {"videos": simplejson.dumps(videos)}, context_instance=RequestContext(request))