Пример #1
0
def sign_post(request):
    if request.method == 'POST':
        guestbook_name = request.POST.get('guestbook_name')
        guestbook_key = Greeting.get_key_from_name(guestbook_name)
        greeting = Greeting(parent=guestbook_key)
        if users.get_current_user():
            greeting.author = users.get_current_user().nickname()
        greeting.content = request.POST.get('content')
        greeting.put()
        return HttpResponseRedirect('/?'+urllib.urlencode({'guestbook_name':guestbook_name}))
    return HttpResponseRedirect('/')
Пример #2
0
 def form_valid(self, form, **kwargs):
     # how to get velue in the form
     guestbook_name = form.cleaned_data['guestbook_name']
     content = form.cleaned_data['content']
     greeting = Greeting(parent=guestbook_key(guestbook_name))
     if users.get_current_user():
         greeting.author = users.get_current_user()
     greeting.guestbook_name = guestbook_name
     greeting.content = content
     greeting.put()
     return super(SignView, self).form_valid(form, **kwargs)
Пример #3
0
    def post(self):
        guestbook_name = self.request.get('guestbook_name',DEFAULT_GUESTBOOK_NAME)
        greeting = Greeting(parent=guestbook_key(guestbook_name))

        if users.get_current_user():
            greeting.author = users.get_current_user()

        greeting.content = self.request.get('content')
        greeting.put()

        query_params = {'guestbook_name': guestbook_name}
        self.redirect('/guestbook/?' + urllib.urlencode(query_params))
Пример #4
0
def sign_post(request):
	if request.method == 'POST':
		guestbook_name = request.POST.get('guestbook_name')
		greeting = Greeting(parent=guestbook_key(guestbook_name))

		if users.get_current_user():
			greeting.author = users.get_current_user()

		greeting.content = request.POST.get('content')
		greeting.put()
		return HttpResponseRedirect('/?' + urllib.urlencode({'guestbook_name':guestbook_name}))
	return HttpResponseRedirect('/')
Пример #5
0
def sign(request, context=None):
    error = []
    # set the default logout location to the frontpage of guestbook
    request.GET = request.GET.copy() # make GET mutable
    request.GET[REDIRECT_FIELD_NAME] = reverse('guestbook.views.list')

    from guestbook.forms import MessageOnlyForm

    if request.method == 'POST':
        form = MessageOnlyForm(request.POST)
        if form.is_valid():
            message = form.cleaned_data['message']
            greeting = Greeting(author = request.user, message = message)
            greeting.put()
            return HttpResponseRedirect(reverse(list))
    else:
        form = MessageOnlyForm()
    return render_to_response('guestbook/sign.html', { 'form': form }, RequestContext(request))