Ejemplo n.º 1
0
 def delete_task(self, task_id, modifier_id):
     task = Task.get_by_key(int(task_id))
     if task.is_trashed:
         tag.delete_tagmodels(modifier_id, model_nk=(Task.get_modelname(), task.uid), modifier_id=modifier_id)
         filex.delete_files(task.creator_id, model_nk=(Task.get_modelname(), task.uid), modifier_id=modifier_id)
         self.delete_taskcomments(task_id, modifier_id)
         self.delete_taskversions(modifier_id, task_id=task.key(), is_affected=None)
         self.delete_taskcomponents(modifier_id, task_id=task.key())
         mclog.delete_mclogs(Task.get_modelname(), task.key(), modifier_id)
         task.delete(modifier_id)
     else:
         if task.creator_id != modifier_id:
             raise Error("task_error_deletesharedtask")
         self.trash_tasks([task.uid], True, modifier_id)
     return True
Ejemplo n.º 2
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
Ejemplo n.º 3
0
 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())