def quote_add(request): # Nothing was POSTed? Just display the form. if not "quote_title" in request.POST: return cnq_render_to_response("quote_add.html", request, {}) # A quote was POSTed. Try to add it. error_message = "" if len(request.POST["quote_title"]) == 0: error_message = "Please enter the quote's title." elif len(request.POST["quote_text"]) == 0: error_message = "Please enter the quote's text." if len(error_message) > 0: return cnq_render_to_response( "quote_add.html", request, { "body_top_error": error_message, "quote_text": request.POST["quote_text"], "quote_title": request.POST["quote_title"], }, ) q = Quote() q.title = request.POST["quote_title"] q.text = request.POST["quote_text"] q.added_by = request.user q.save() # We should redirect to /quotes/<new_id>/ here, with possibly the # message "Quote added" at the top. return HttpResponseRedirect("/quotes/%d/" % q.id)
def quote_add(request): # Nothing was POSTed? Just display the form. if not 'quote_title' in request.POST: return cnq_render_to_response('quote_add.html', request, {}) # A quote was POSTed. Try to add it. error_message = "" if len(request.POST['quote_title']) == 0: error_message = "Please enter the quote's title." elif len(request.POST['quote_text']) == 0: error_message = "Please enter the quote's text." if len(error_message) > 0: return cnq_render_to_response( 'quote_add.html', request, { 'body_top_error': error_message, 'quote_text': request.POST['quote_text'], 'quote_title': request.POST['quote_title'], }) q = Quote() q.title = request.POST['quote_title'] q.text = request.POST['quote_text'] q.added_by = request.user q.save() # We should redirect to /quotes/<new_id>/ here, with possibly the # message "Quote added" at the top. return HttpResponseRedirect("/quotes/%d/" % q.id)
def add_data(): u_test = User( username="******", first_name="Jan", last_name="Tester", password=make_password("testuser"), ) u_test.save() up = UserProfile( user=u_test, is_member=True, blog_name="Zapagaloogah", blog_url="https://zapagaloogah.spotblog.unk", ) up.save() u_admin = User( username="******", first_name="Sten", last_name="Admin", password=make_password("adminuser"), ) u_admin.save() up = UserProfile( user=u_admin, is_member=True, ) up.save() n = News( title="Dit is nieuws", text="En dit is de omschrijving", added_by=u_admin, ) n.save() q1 = Quote( title="Zo hoort het!", text="<Habbie> wat een kniesoor\n<Domilijn> Gezondheid!", added_by=u_test, ) q1.save() q2 = Quote( title="Grote jongen", text= "12:31 < RS-232> Emphyrio: dan nee dank je. ik heb 11\" en wil dat formaat graag houden.", added_by=u_test, ) q2.save()
def add_data(): u_test = User( username="******", first_name="Jan", last_name="Tester", password=make_password("testuser"), ) u_test.save() up = UserProfile( user=u_test, is_member=True, blog_name="Zapagaloogah", blog_url="https://zapagaloogah.spotblog.unk", ) up.save() u_admin = User( username="******", first_name="Sten", last_name="Admin", password=make_password("adminuser"), ) u_admin.save() up = UserProfile( user=u_admin, is_member=True, ) up.save() n = News( title = "Dit is nieuws", text = "En dit is de omschrijving", added_by = u_admin, ) n.save() q1 = Quote( title="Zo hoort het!", text="<Habbie> wat een kniesoor\n<Domilijn> Gezondheid!", added_by=u_test, ) q1.save() q2 = Quote( title="Grote jongen", text="12:31 < RS-232> Emphyrio: dan nee dank je. ik heb 11\" en wil dat formaat graag houden.", added_by=u_test, ) q2.save()