예제 #1
0
    def get(self):
        uri_post = self.request.path_info
        uri_post = uri_post.replace("/_edit", "")

        param = self.request.get('v')
        if not param:
            entry = db.GqlQuery(
                "SELECT * FROM WikiPost WHERE uri=:1 ORDER BY created DESC limit 1",
                uri_post).get()
        else:
            entry = wiki_post.WikiPost.get_by_id(int(param))

        cookie_val = self.request.cookies.get('valid')
        if not cookie_val:
            self.render("view_login.html", entry=entry)
        else:
            username = hash_cookie.check_secure_val(cookie_val)
            if entry:
                self.render("edit.html",
                            uri=uri_post,
                            username=username,
                            content=entry.content)
            else:
                self.render("edit.html",
                            uri=uri_post,
                            username=username,
                            content="")
예제 #2
0
    def get(self):
        #Tenemos que comprobar si existe cookie con usuario
        # Si no existe cookie con usuario debemos redirigir a view_login.html
        # Si existe cookie de usuario debemos redirigir a view_user.html
        #En ambos casos hay que ver la URI para ver el post y dar una vista de su contenido
        # Por tanto, primero buscamos el contenido asociado a esa URI
        uri_post = self.request.path_info
        uri_history = DOCUMENT_ROOT + "/_history" + uri_post.replace(
            DOCUMENT_ROOT, "")

        param = self.request.get('v')
        if not param:
            entry = db.GqlQuery(
                "SELECT * FROM WikiPost WHERE uri=:1 ORDER BY created DESC limit 1",
                uri_post).get()
        else:
            entry = wiki_post.WikiPost.get_by_id(int(param))

        cookie_val = self.request.cookies.get('valid')
        if not cookie_val:
            self.render("view_login.html",
                        uri_history=uri_history,
                        entry=entry)
        else:
            uri_edit = uri_history.replace("/_history", "/_edit")
            if entry:
                username = hash_cookie.check_secure_val(cookie_val)
                self.render("view_user.html",
                            uri_edit=uri_edit,
                            uri_history=uri_history,
                            username=username,
                            entry=entry)
            else:
                self.redirect(uri_edit)
예제 #3
0
  def get(self):
    uri_post = self.request.path_info
    uri_post = uri_post.replace("/_edit", "")
    
    param = self.request.get('v')
    if not param:
      entry = db.GqlQuery("SELECT * FROM WikiPost WHERE uri=:1 ORDER BY created DESC limit 1", uri_post).get()
    else:
      entry = wiki_post.WikiPost.get_by_id(int(param))

    cookie_val = self.request.cookies.get('valid')
    if not cookie_val:
      self.render("view_login.html", entry = entry)
    else:
      username = hash_cookie.check_secure_val(cookie_val)
      if entry:
        self.render("edit.html", 
                    uri = uri_post, 
                    username = username, 
                    content = entry.content)
      else:
        self.render("edit.html", 
                    uri = uri_post, 
                    username = username, 
                    content = "") 
예제 #4
0
  def get(self):
    #Tenemos que comprobar si existe cookie con usuario
    # Si no existe cookie con usuario debemos redirigir a view_login.html
    # Si existe cookie de usuario debemos redirigir a view_user.html
    #En ambos casos hay que ver la URI para ver el post y dar una vista de su contenido
    # Por tanto, primero buscamos el contenido asociado a esa URI
    uri_post = self.request.path_info
    uri_history = DOCUMENT_ROOT + "/_history" + uri_post.replace(DOCUMENT_ROOT, "")

    param = self.request.get('v')
    if not param:
      entry = db.GqlQuery("SELECT * FROM WikiPost WHERE uri=:1 ORDER BY created DESC limit 1",uri_post).get()
    else:
      entry = wiki_post.WikiPost.get_by_id(int(param))

    cookie_val = self.request.cookies.get('valid')
    if not cookie_val:
      self.render("view_login.html", uri_history = uri_history, entry = entry)
    else:
      uri_edit = uri_history.replace("/_history", "/_edit")
      if entry:	
        username = hash_cookie.check_secure_val(cookie_val)
        self.render("view_user.html", 
                    uri_edit = uri_edit, 
                    uri_history = uri_history, 
                    username = username, 
                    entry = entry)
      else:
        self.redirect(uri_edit)
예제 #5
0
 def get(self):
     cookie_val = self.request.cookies.get('valid')
     if cookie_val:
         username = hash_cookie.check_secure_val(cookie_val)
         if cookie_val:
             self.render("welcome.html", username=username)
         else:
             self.redirect("/blog/signup")
예제 #6
0
	def get(self):
            cookie_val=self.request.cookies.get('valid')
	    if cookie_val:
               username=hash_cookie.check_secure_val(cookie_val)
               if cookie_val:
		  self.render("welcome.html", username=username)
	       else:
		  self.redirect("/blog/signup")
예제 #7
0
    def post(self):
        uri_edit = self.request.path_info
        uri_post = uri_edit.replace("/_edit", "")
        content = self.request.get("content")

        entry = wiki_post.WikiPost(uri=uri_post, content=content)
        entry.put()
        entry.id = entry.key().id()
        entry.uri_history_view = uri_post + "?v=" + str(entry.key().id())
        entry.uri_history_edit = uri_edit + "?v=" + str(entry.key().id())
        entry.put()

        cookie_val = self.request.cookies.get('valid')
        if cookie_val:
            username = hash_cookie.check_secure_val(cookie_val)
            self.redirect(uri_post)
예제 #8
0
  def post(self):
    uri_edit = self.request.path_info
    uri_post = uri_edit.replace("/_edit", "")
    content = self.request.get("content")
    
    entry = wiki_post.WikiPost(uri = uri_post, content = content)
    entry.put()
    entry.id = entry.key().id()
    entry.uri_history_view = uri_post + "?v=" + str(entry.key().id())
    entry.uri_history_edit = uri_edit + "?v=" + str(entry.key().id())
    entry.put()

    cookie_val = self.request.cookies.get('valid')
    if cookie_val:
      username = hash_cookie.check_secure_val(cookie_val)
      self.redirect(uri_post)
예제 #9
0
 def get(self):
   uri_post = self.request.path_info
   uri_post = uri_post.replace("/_history", "")
   
   entries = db.GqlQuery("SELECT * FROM WikiPost WHERE uri=:1 ORDER BY created DESC", uri_post)
   cookie_val = self.request.cookies.get('valid')
   if entries:
     if not cookie_val:
       self.render("history_view.html", 
                   uri_view = uri_post, 
                   entries = entries)
     else:
       uri_edit = DOCUMENT_ROOT + "/_edit" + uri_post.replace(DOCUMENT_ROOT, "")
       username = hash_cookie.check_secure_val(cookie_val)
       self.render("history_edit.html", 
                   uri_edit = uri_edit, 
                   uri_view = uri_post, 
                   username = username, 
                   entries = entries)
예제 #10
0
    def get(self):
        uri_post = self.request.path_info
        uri_post = uri_post.replace("/_history", "")

        entries = db.GqlQuery(
            "SELECT * FROM WikiPost WHERE uri=:1 ORDER BY created DESC",
            uri_post)
        cookie_val = self.request.cookies.get('valid')
        if entries:
            if not cookie_val:
                self.render("history_view.html",
                            uri_view=uri_post,
                            entries=entries)
            else:
                uri_edit = DOCUMENT_ROOT + "/_edit" + uri_post.replace(
                    DOCUMENT_ROOT, "")
                username = hash_cookie.check_secure_val(cookie_val)
                self.render("history_edit.html",
                            uri_edit=uri_edit,
                            uri_view=uri_post,
                            username=username,
                            entries=entries)