Esempio n. 1
0
 def post(self):
     bm = self.get_bm()
     if bm is None:
         self.error(400)
         return
     parent_key = str(bm.bm_parent.key()) if bm.bm_parent else ''
     if self.request.get("action") == "Delete":
         bm.delete()
         self.redirect("/my_bookmarks?key=" + parent_key)
         return
     data = {}
     data["bm_title"] = self.request.get("bm_title", default_value="")
     data["url"] = self.request.get("url", default_value="")
     data["shared"] = True if self.request.get(
         "shared", default_value=None) else False
     data["bm_parent"] = bm.bm_parent
     err_msg = helper.validate_bookmark_data(data)
     if not err_msg:
         bm.title = data["bm_title"]
         bm.url = data["url"]
         bm.shared = data["shared"]
         bm.put()
         self.redirect("/my_bookmarks?key=" + parent_key)
     else:
         self.render("edit_bookmark", \
             { "bm": data, 
               "err_msg": err_msg,
               "current_folder_path": helper.get_folder_path(bm.bm_parent),
             })
Esempio n. 2
0
 def post(self):
     input_data = {
         "bm_title": self.request.get(
             "bm_title", default_value="").strip(),
         "url": self.request.get(
             "url", default_value="").strip(),
         "shared": True if self.request.get(
             "shared", default_value=False) else False,
     }
     parent = self.get_parent()
     err_msg = helper.validate_bookmark_data(input_data)
     if err_msg:
         input_data["err_msg"] = err_msg
         input_data["current_folder_path"] = \
                 helper.get_folder_path(parent)
         self.render("add_bookmark", input_data)
         return
     bm_path = helper.get_bm_path(parent) 
     bm = Bookmark(
             title=input_data["bm_title"],
             url=input_data["url"],
             shared=input_data["shared"],
             is_folder=False,
             bm_parent=parent,
             bm_path=bm_path
     )
     bm.put()
     parent_key = str(parent.key()) if parent else ""
     self.redirect("/my_bookmarks?key=" + parent_key)