def get(self): cookie = self.request.cookies.get('user_id') username = utils.get_username_from_cookie(cookie) if username: self.render("askquestion.html", user=username) else: self.redirect("/")
def post(self, pagepath): cookie = self.request.cookies.get('user_id') username = utils.get_username_from_cookie(cookie) logging.error("In edit page post: pagepath %s username %s\ncookie %s\n", pagepath, username, cookie) logging.error("Pagepath now %s\n", pagepath) if username: edited_content = self.request.get('content') logging.error("content = %s\n", edited_content) # see if this page already exists mywikipage = get_wikipage_by_path(pagepath) if edited_content and pagepath: if mywikipage: # already existing page, just update content mywikipage.content = edited_content else: # create new wiki page mywikipage = Wiki(parent = wiki_key(), urlpath = pagepath, content = edited_content) # store new or modified page mywikipage.put() # redirect to the wiki page and display with updated contents logging.error("redirecting to = %s\n", pagepath) self.redirect(pagepath)
def get(self, pagepath): cookie = self.request.cookies.get('user_id') # Look up pagepath for existing page. If exists set pagetext to contents, else pagetext = None username = utils.get_username_from_cookie(cookie) logging.error("editpage get, username %s pagepage %s\n", username, pagepath) if username: mywikipage = get_wikipage_by_path(pagepath) if mywikipage: content = mywikipage.content else: content = "" logging.error("content is %s\n", content) self.render("editpage.html", user = utils.get_username_from_cookie(cookie), editurl = None, content = content)
def post(self): cookie = self.request.cookies.get('user_id') username = utils.get_username_from_cookie(cookie) questionid = self.request.get("foo") address_k = db.Key.from_path('Querydbase', int(questionid)) address = db.get(address_k) address.likes = address.likes + 1 address.put() self.redirect('/showqu')
def post(self): cookie = self.request.cookies.get('user_id') username = utils.get_username_from_cookie(cookie) a = self.request.get("key") b = self.request.get("comment") a = a.replace(" ", "") u = Querydbase.gql("WHERE questionid = '%s'" % a).get() cor = Reply(post=a, author=username, text=b) cor.put() self.redirect('/showqu')
def get(self): cookie = self.request.cookies.get('user_id') username = utils.get_username_from_cookie(cookie) # logging.error("wikipage get, cookie %s pagepath %s\n", cookie, pagepath) # editurl = "/_edit" + pagepath # mywikipage = get_wikipage_by_path(pagepath) # If page already exists in Wiki, retreive content and display if username: self.redirect("/showqu") else: self.render("index.html")
def get(self): cookie = self.request.cookies.get('user_id') username = utils.get_username_from_cookie(cookie) # logging.error("wikipage get, cookie %s pagepath %s\n", cookie, pagepath) if username: a = "Webprogramming" h = Querydbase.all().filter("subject = ", a) com = Reply.all() f = datetime.timedelta(0, 19800) self.render("base.html", h=h, f=f, user=username, comment=com, subject=a) else: self.response.out.write("Sdf")
def get(self,pagepath): cookie = self.request.cookies.get('user_id') username = utils.get_username_from_cookie(cookie) logging.error("wikipage get, cookie %s pagepath %s\n", cookie, pagepath) editurl = "/_edit" + pagepath mywikipage = get_wikipage_by_path(pagepath) # If page already exists in Wiki, retreive content and display if mywikipage: content = mywikipage.content self.render("wikipage.html", user = username, editurl = editurl, content = content) # If page doesn't exist, redirect to an edit page assuming user is logged in elif username: self.redirect(editurl) else: self.render("wikipage.html", user = username, editurl = editurl, content = "")
def post(self): cookie = self.request.cookies.get('user_id') username = utils.get_username_from_cookie(cookie) question = self.request.get('question') subject = self.request.get('subject') if question: published = datetime.datetime.now() created = datetime.datetime.now() count = Querydbase.all().count() g = Querydbase(questionid=str(count), username=username, subject=subject, question=question) count = count + 1 g.put() # self.response.out.write(subject) self.redirect('/') else: self.redirect("/postquestion")