def execute(self): rtn = self._new_rtn() worksheet = self._get_model_parameter(Worksheet) if strutil.is_empty(worksheet.key()): worksheet.creator_id = self._get_user_id() worksheet = TaskService.get_instance().create_worksheet(worksheet, self._get_user_id()) else: worksheet = TaskService.get_instance().update_worksheet(worksheet, self._get_user_id()) rtn.set_data(worksheet) return rtn.to_json()
def to_dict(self): self.planProgress = self.get_plan_progress() self.creatorDisplayName = user.get_user_display_name(self.creator_id) from contact.contactservice import ContactService self.taskAssigneeName = ContactService.get_instance().get_contact_name(self.assignee_id) from task.taskservice import TaskService self.componentKeys = map(lambda x: x.component_id, TaskService.get_instance().fetch_taskcomponents(self.key())) self.affectedVersionKeys = map(lambda x: x.version_id, TaskService.get_instance().fetch_taskversions(self.key(), True)) self.fixedVersionKeys = map(lambda x: x.version_id, TaskService.get_instance().fetch_taskversions(self.key(), False)) tdt = Model.to_dict(self) tdt['storyPoints'] = "%0.1f" % self.story_points if self.story_points is not None else "" return tdt
def execute(self): rtn = self._new_rtn() taskcomment = self._get_model_parameter(TaskComment) t = taskcomment.tc_content.replace(" ", "") if strutil.is_empty(t): raise RequiredError("task_label_tccontent") if strutil.is_empty(taskcomment.key()): taskcomment.creator_id = self._get_user_id() taskcomment = TaskService.get_instance().create_taskcomment(taskcomment, self._get_user_id()) else: taskcomment = TaskService.get_instance().update_taskcomment(taskcomment, self._get_user_id()) taskcomment.userName = user.get_user_display_name(taskcomment.creator_id) rtn.set_data(taskcomment) return rtn.to_json()
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
def execute(self): rtn = self._new_rtn() task_id = self._get_int_parameter("taskKey") worksheet_id = self._get_int_parameter("worksheetKey", default=model.EMPTY_UID) status = TaskService.get_instance().recover_task(task_id, worksheet_id, self._get_user_id()) rtn.set_data(status) return rtn.to_json()
def execute(self): rtn = self._new_rtn() offset = self._get_int_parameter('offset', 1) limit = self._get_int_parameter('limit', 20) filters = self._get_str_parameter('filters') filters = jsonutil.to_dict(filters) pager = TaskService.get_instance().fetch_tasks(self._get_user_id(), filters=filters, limit=limit, offset=offset) rtn.set_data(pager) return rtn.to_json()
def execute(self): rtn = self._new_rtn() worksheets = TaskService.get_instance().fetch_worksheets(self._get_user_id()) std = stdModel() workbasket = Worksheet() workbasket.uid = model.EMPTY_UID workbasket.ws_name = i18n.get_i18n_message(conf.get_preferred_language(), "task_label_workbasket") workbasket.taskcount = TaskService.get_instance().get_taskcount(False, self._get_user_id(), worksheet_id=model.EMPTY_UID) workbasket.creator_id = self._get_user_id() worksheets.insert(0, workbasket) trash = Worksheet() trash.uid = -100 trash.ws_name = i18n.get_i18n_message(conf.get_preferred_language(), "task_label_recyclebin") trash.taskcount = TaskService.get_instance().get_taskcount(True, self._get_user_id()) trash.creator_id = self._get_user_id() worksheets.append(trash) std.worksheets = worksheets std.contactGroups = ContactService.get_instance().fetch_my_groups(self._get_user_id()) stmworksheets = TaskService.get_instance().fetch_worksheets(self._get_user_id(), sharetome=True) std.worksheets.extend(stmworksheets) std.worksheetComponents = {} std.worksheetVersions = {} std.worksheetContacts = {} for worksheet in std.worksheets: if worksheet.group_id != None and worksheet.group_id != model.EMPTY_UID: std.worksheetComponents[worksheet.key()] = ContactService.get_instance().fetch_groupcomponents(worksheet.group_id) std.worksheetVersions[worksheet.key()] = ContactService.get_instance().fetch_groupversions(worksheet.group_id) std.worksheetContacts[worksheet.key()] = ContactService.get_instance().fetch_contacts_by_group(worksheet.group_id) else: myself = ContactService.get_instance().get_myself(self._get_user_id()) if myself is not None: std.worksheetContacts[worksheet.key()] = [myself] rtn.set_data(std) return rtn.to_json()
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()
def get_progress_data(self, user_id, start_date, end_date, worksheet_ids, group_id=None, assignee_ids=None): if worksheet_ids is None or len(worksheet_ids) == 0: raise RequiredError("task_label_worksheet") if start_date is None: raise RequiredError(label="rept_label_startdate") if end_date is None: raise RequiredError(label="rept_label_enddate") if end_date <= start_date: raise CompareError( label="rept_label_enddate", limitlabel="rept_label_startdate", limit=start_date, operator=">" ) today = dtutil.localtoday(conf.get_preferred_timezone()) finishtaskcount = 0 progressLine = stdModel(plan={}, actual={}, forecast={}) progressBar = {} for priority in i18n.get_i18n_messages( conf.get_preferred_language(), "task_priority_code", rtn_dict=True ).keys(): statusTaskCount = [0, 0, 0] # planFinishCount, actualFinishCount, cancelCount progressBar[priority] = statusTaskCount rtn = stdModel(progressLine=progressLine, progressBar=progressBar, deviationTasks=[]) dates = self.get_workdates(start_date, end_date, group_id) for date in dates: progressLine.plan[date] = [date, 0] # [date, finish count] if date <= today: progressLine.actual[date] = [date, 0] # [date, finish count] else: progressLine.forecast[date] = [date, 0] # [date, finish count] tasks = self.fetch_tasks(user_id, None, worksheet_ids, assignee_ids) for task in tasks: for date, planstd in progressLine.plan.items(): if date <= today and task.t_status_code == "task_code_closed" and task.actual_finishdate <= date: progressLine.actual[date][1] += 1 if task.due_finishdate <= date and task.t_status_code != "task_code_cancel": planstd[1] += 1 if task.t_status_code != "task_code_closed" and task.t_status_code != "task_code_cancel": progress = task.get_plan_progress_int() if progress > task.actual_progress: task.deviationStatus = "rept_label_deviationdelay" elif progress < task.actual_progress: task.deviationStatus = "rept_label_deviationadvance" if progress != task.actual_progress: task.assigneeName = ContactService.get_instance().get_contact_name(task.assignee_id) comments = TaskService.get_instance().fetch_taskcomments(task.key(), limit=1) task.lastComment = comments[0].tc_content if len(comments) > 0 else "" rtn.deviationTasks.append(task) else: if ( task.t_status_code == "task_code_closed" and task.actual_startdate >= start_date and task.actual_finishdate <= today ): finishtaskcount += 1 statusTaskCount = progressBar[task.t_priority_code] if task.due_finishdate <= end_date: if task.t_status_code == "task_code_cancel": statusTaskCount[2] += 1 else: statusTaskCount[0] += 1 if task.t_status_code == "task_code_closed": statusTaskCount[1] += 1 speed = finishtaskcount / float(self.get_workdays(start_date, today, None, None)) for date, forestd in progressLine.forecast.items(): forestd[1] = finishtaskcount + speed * ((date - today).days + 1) if end_date > today: progressLine.forecast[today] = [today, float(progressLine.actual[today][1])] progressLine.plan = progressLine.plan.values() progressLine.actual = progressLine.actual.values() progressLine.forecast = progressLine.forecast.values() return rtn
def execute(self): rtn = self._new_rtn() status = TaskService.get_instance().empty_trash(self._get_user_id(), self._get_user_id()) rtn.set_data(status) return rtn.to_json()
def execute(self): rtn = self._new_rtn() worksheet_id = self._get_int_parameter("worksheetKey") status = TaskService.get_instance().delete_worksheet(worksheet_id, self._get_user_id()) rtn.set_data(status) return rtn.to_json()
def execute(self): rtn = self._new_rtn() comment_id = self._get_int_parameter("commentKey") status = TaskService.get_instance().delete_taskcomment(comment_id, self._get_user_id()) rtn.set_data(status) return rtn.to_json()
def _loadWorksheets(self): worksheets = TaskService.get_instance().fetch_my_worksheets(self._get_user_id()) return worksheets
def delete_groupversion(self, version_id, modifier_id): groupversion = GroupVersion.get_by_key(version_id) groupversion.delete(modifier_id) from task.taskservice import TaskService TaskService.get_instance().delete_taskversions(modifier_id, version_id=version_id) return True
def delete_groupcomponent(self, component_id, modifier_id): groupcomponent = GroupComponent.get_by_key(component_id) groupcomponent.delete(modifier_id) from task.taskservice import TaskService TaskService.get_instance().delete_taskcomponents(modifier_id, component_id=component_id) return True