def edit(request,kind,id): newtitle = request.GET.get('title') isauth = request.user.is_authenticated() if(isauth): message = "Logged in as " + request.user.username if(kind == 'film'): if(id != '0'): obj = get_object_or_404(Film, pk = id) message2 ="Edit movie" else: obj=Film(title=newtitle, updatedon=datetime.datetime.now()) obj.save() message2 = "Fill in the information of the movie you want to add" return render_to_response('findost/editfilmform.html', {'id' : id, 'message2' : message2, 'message' : message, 'obj' : obj, 'isauth' : isauth}, context_instance=RequestContext(request)) if(kind == 'episode'): if(id != '0'): obj = get_object_or_404(Episode, pk = id) message2="Edit episode" else: obj=Episode(number=1,seasonnb=1) s = Show(title=newtitle) s.save() obj.show = s obj.updatedon=datetime.datetime.now() obj.save() message2 = "Fill in the information of the show you want to add" return render_to_response('findost/editepisodeform.html', {'id' : id, 'message':message, 'message2' : message2, 'obj' : obj, 'isauth' : isauth},context_instance=RequestContext(request)) else: raise Http404
def find_and_add_film(l): i = 3 temp = '' while (l[i] != '"' and i<len(l)-1): temp = temp + l[i] i=i+1 if(i<len(l)-1): filmtitle = temp temp = '' i=i+3 while(l[i] != ')' and l[i] != '/' and i<len(l)-1): temp = temp + l[i] i=i+1 if(i<len(l)-1): date = temp lifilm = Film.objects.filter(title=filmtitle).filter(cameouton=int(date)) if(lifilm): film = lifilm[0] else: print (filmtitle + ', ' + date) film = Film(title=filmtitle,cameouton=int(date)) film.updatedon=datetime.datetime.now() film.save() return film