Пример #1
0
    def fetch_tasks(self, user_id, group_id, worksheet_ids, assignee_ids):

        if group_id is not None:
            my_group_ids = ContactService.get_instance().fetch_my_groups(user_id, onlyrtnids=True)
            if group_id not in my_group_ids:
                raise UnauthorizedError()
            worksheet_ids = self.fetch_worksheet_ids(group_id, worksheet_ids=worksheet_ids)
            assignee_ids = self.fetch_assignee_ids(group_id, assignee_ids=assignee_ids)
        else:
            my_worksheet_ids = TaskService.get_instance().fetch_my_worksheets(user_id, onlyrtnids=True)
            worksheet_ids = list(set(worksheet_ids).intersection(set(my_worksheet_ids)))

        query = Task.all("a")
        query.what("a.uid")
        query.what("a.t_subject")
        query.what("a.due_startdate")
        query.what("a.due_finishdate")
        query.what("a.actual_progress")
        query.what("a.actual_startdate")
        query.what("a.actual_finishdate")
        query.what("a.t_status_code")
        query.what("a.assignee_id")
        if worksheet_ids != None and len(worksheet_ids) > 0:
            query.filter("a.worksheet_id in", worksheet_ids, wrapper=False)
        if assignee_ids != None and len(assignee_ids) > 0:
            query.filter("a.assignee_id in", assignee_ids, wrapper=False)
        tasks = query.fetch()
        return tasks
Пример #2
0
 def delete_contact(self, contact_id, modifier_id):
     contact = Contact.get_by_key(int(contact_id))
     if contact.is_trashed:
         contact.delete(modifier_id)
         self.delete_contactgroups(modifier_id, contact_id=contact_id)
     else:
         if contact.creator_id != modifier_id:
             raise Error("cont_error_deletesharedcontact")
         
         query = Task.all()
         query.filter("assignee_id =", contact_id)
         query.filter("is_trashed =", False)
         if query.count() > 0:
             raise Error('cont_error_assignedtasks')
         else:
             self.trash_contacts([contact.uid], True, modifier_id)
     return True
Пример #3
0
 def execute(self):
     rtn = self._new_rtn()
     task = self._get_model_parameter(Task)
     affectedVersionKeys = self._get_str_parameter("affectedVersionKeys", '')
     task.affected_version_ids = map(int, affectedVersionKeys.split(",")) if affectedVersionKeys.strip() != '' else []
     fixedVersionKeys = self._get_str_parameter("fixedVersionKeys", '')
     task.fixed_version_ids = map(int, fixedVersionKeys.split(",")) if fixedVersionKeys.strip() != '' else []
     componentKeys = self._get_str_parameter("componentKeys", '')
     task.component_ids = map(int, componentKeys.split(",")) if componentKeys.strip() != '' else []
     
     if strutil.is_empty(task.key()):
         task.creator_id = self._get_user_id()
         task = TaskService.get_instance().create_task(task, self._get_user_id())
         task.taskComments = []
         task.mclogs = []
     else:
         task = TaskService.get_instance().update_task(task, self._get_user_id())
         task.taskComments = TaskService.get_instance().fetch_taskcomments(task.key())
         task.mclogs = mclog.fetch_mclogs(Task.get_modelname(), task.key(), worksheet_id=TaskService.get_instance().get_worksheet_name, assignee_id=ContactService.get_instance().get_contact_name)
     
     rtn.set_data(task)
     return rtn.to_json()