Exemplo n.º 1
0
def sign(request):
  form = GuestbookForm(request.POST)
  if form.is_valid():
    post = Post(message=form.clean_data['message'])
    if users.GetCurrentUser():
      post.author = users.GetCurrentUser()
  
    post.put()

  return HttpResponseRedirect('/')
Exemplo n.º 2
0
def sign(request):
    form = GuestbookForm(request.POST)
    if form.is_valid():
        post = Post(message=form.clean_data['message'])
        if users.GetCurrentUser():
            post.author = users.GetCurrentUser()

        post.put()

    return HttpResponseRedirect('/')
Exemplo n.º 3
0
Arquivo: views.py Projeto: chemt/vsad
def guestbook(request):
    added = False
	
    if request.method == 'POST': # If the form has been submitted...
        form = GuestbookForm(request.POST)
        if form.is_valid():
            form.save()
            data = form.cleaned_data
            message_text = u'Імя: %s \n Відгук: %s' % (data['name'], data['text'])
            send_mail(u'Новий відгук на сайті', message_text, '*****@*****.**',
                        REPORT_EMAILS, fail_silently=False)
            added = True
            form = GuestbookForm()

    else:
        form = GuestbookForm()

    entries = GuestBook.objects.all().order_by("-date")
    templates = {'form': form, 'entries': entries, 'added':added }
    c = RequestContext(request, templates)
    return render_to_response("guestbook.html", c)
Exemplo n.º 4
0
def guestbook(request):
	instance = Guestbook(display=True,ip=request.META.get('HTTP_X_REAL_IP',request.META['REMOTE_ADDR']))
	guestbook_form = GuestbookForm(instance=instance)
	start_at = max(int(request.GET.get('start_at','0')),0)
	items_per_page = 20

	if request.method == "POST":
		guestbook_form = GuestbookForm(request.POST, instance=instance)
		if guestbook_form.is_valid():
			guestbook_form.save(request)
			messages.success(request, _("Guestbook entry added"))
			return HttpResponseRedirect('/guestbook/')


	context = {
			'guestbook_form': guestbook_form
			, 'entries': Guestbook.objects.filter(display=True).order_by('-date')[start_at:start_at+items_per_page]
			, 'display_next_page':len(Guestbook.objects.filter(display=True).order_by('-date')[start_at+items_per_page:]) > 0
			, 'display_last_page':start_at>0
			, 'next_startat':start_at+items_per_page
			, 'last_startat':max(start_at-items_per_page,0)
			}
	return HttpResponse(loader.get_template("guestbook.html").render(RequestContext(request,context)))