Пример #1
0
 def empty_trash(self, user_id, modifier_id):
     query = Task.all()
     query.filter("is_trashed =", True)
     query.filter("creator_id =", user_id)
     tasks = query.fetch()
     for task in tasks:
         self.delete_task(task.key(), modifier_id)
     return True
Пример #2
0
 def delete_worksheet(self, worksheet_id, modifier_id):
     worksheet = Worksheet.get_by_key(worksheet_id)
     worksheet.delete(modifier_id)
     query = Task.all()
     query.filter("worksheet_id =", worksheet_id)
     query.set("worksheet_id", EMPTY_UID)
     query.set("is_trashed", True)
     query.update(modifier_id)
     query = Worksheet.all()
     return True
Пример #3
0
 def get_taskcount(self, is_trashed, user_id, worksheet_id=None, is_complete=None , ex_assignee_id=None):
     query = Task.all()
     query.filter("is_trashed =", is_trashed)
     if worksheet_id != None and worksheet_id != model.EMPTY_UID:
         query.filter("worksheet_id =", worksheet_id)
     elif worksheet_id == model.EMPTY_UID:
         query.filter("worksheet_id =", worksheet_id)
         query.filter("creator_id =", user_id)
     else:
         query.filter("creator_id =", user_id)
     if is_complete != None and is_complete == True:
         query.filter("t_status_code =", 'task_code_closed')
     if is_complete != None and is_complete != True:
         query.filter("t_status_code !=", 'task_code_closed')
     if ex_assignee_id != None:
         query.filter("assignee_id !=", ex_assignee_id)
     
     return query.count()
Пример #4
0
 def fetch_tasks(self, user_id, whats=None, filters=None, limit=20, offset=0):
     def append_filters(query):
         for ft in filters:
             for (key, value) in ft.items():
                 for nr in TASKRESOLVERS:
                     nrinst = nr(key, value)
                     query.extend(nrinst, user_id=user_id)
     
     if whats == None:
         query = Task.all(alias="a")
         for key in Task.get_properties(persistent=True).keys():
             query.what("a.%s" % key, alias=key)
     else:
         query = stdModel.all()
         query.model(Task.get_modelname(), alias="a")
         for what in whats:
             query.what("a.%s" % what, alias=what)
     
     query.select("DISTINCT")
     query.what("a.uid", alias="uid")
     
     worksheet_ids = self.fetch_my_worksheets(user_id, onlyrtnids=True)
     if len(worksheet_ids) > 0:
         query.filter("a.worksheet_id in", worksheet_ids, parenthesis="(")
         query.filter("a.creator_id =", user_id, logic="or", parenthesis=")")
     else:
         query.filter("a.creator_id =", user_id)
     
     query.order("-a.uid")
     if filters is not None:
         append_filters(query)
     
     if not query.has_filter("a.is_trashed"):
         query = query.filter("a.is_trashed =", False)
     
     def task_proc(task):
         task.mclogs = mclog.fetch_mclogs(Task.get_modelname(), task.key(), worksheet_id=self.get_worksheet_name, assignee_id=ContactService.get_instance().get_contact_name)
         task.taskComments = self.fetch_taskcomments(task.key())
         
     pager = query.fetch(limit, offset, paging=True, model_proc=task_proc)
     return pager