예제 #1
0
 def fetch_notes(self, user_id, filters=None, limit=20, offset=0):
     
     def append_filters(query):
         for ft in filters:
             for (key, value) in ft.items():
                 for nr in NOTERESOLVERS:
                     nrinst = nr(key, value)
                     query.extend(nrinst)
                 
     query = Note.all(alias="a")
     query.select("DISTINCT")
     query.order("-a.uid")
     
     notebook_ids = self.fetch_my_notebooks(user_id, onlyrtnids=True)
     if len(notebook_ids) > 0:
         query.filter("a.notebook_id in", notebook_ids, parenthesis="(")
         query.filter("a.creator_id =", user_id, logic="or", parenthesis=")")
     else:
         query.filter("a.creator_id =", user_id)
     
     if filters is not None:
         append_filters(query)
         
     if not query.has_filter("a.is_trashed"):
         query = query.filter("a.is_trashed =", False)
         
     def note_proc(note):
         ''''''
     
     return query.fetch(limit, offset, paging=True, model_proc=note_proc)
예제 #2
0
 def delete_notebook(self, notebook_id, modifier_id):
     notebook = Notebook.get_by_key(notebook_id)
     notebook.delete(modifier_id)
     query = Note.all()
     query.filter("notebook_id =", notebook_id)
     query.set("notebook_id", EMPTY_UID)
     query.set("is_trashed", True)
     query.update(modifier_id)
     query = Notebook.all()
     return True
예제 #3
0
 def get_notecount(self, is_trashed, user_id, notebook_id=None):
     query = Note.all()
     query.filter("is_trashed =", is_trashed)
     if notebook_id != None and notebook_id != model.EMPTY_UID:
         query.filter("notebook_id =", notebook_id)
     elif notebook_id == model.EMPTY_UID:
         query.filter("notebook_id =", notebook_id)
         query.filter("creator_id =", user_id)
     else:
         query.filter("creator_id =", user_id)
     if notebook_id != None:
         query.filter("notebook_id =", notebook_id)
     return query.count()
예제 #4
0
 def empty_trash(self, user_id, modifier_id):
     query = Note.all()
     query.filter("is_trashed =", True)
     query.filter("creator_id =", user_id)
     status = query.delete(modifier_id)
     return status