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)
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('/')
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))
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('/')
def create_greeting(request): if request.method == "POST": greeting = Greeting() greeting.content = request.POST.get("content") greeting.isprivate = request.POST.get("isprivate") if greeting.isprivate == None: greeting.isprivate = 0 try: user_id = request.session["user_id"] except KeyError: user_id = User.objects.all().filter(username="******")[0].id greeting.author = User.objects.get(id=user_id) greeting.save() return HttpResponseRedirect("/greeting/")
def create_greeting(request): if request.method == 'POST': greeting = Greeting() greeting.content = request.POST.get('content') greeting.isprivate = request.POST.get('isprivate') if greeting.isprivate == None: greeting.isprivate = 0 try: user_id = request.session['user_id'] except KeyError: user_id = User.objects.all().filter( username='******')[0].id greeting.author = User.objects.get( id = user_id) greeting.save() return HttpResponseRedirect('/greeting/')