def create(project_id,subject,priority,assign_to,description,category_id,creator): session = database.get_session() subject = subject.strip() issue = Issue() issue.ProjectId = project_id issue.CategoryId = category_id issue.Subject = subject issue.Priority = priority issue.Description = description issue.Status = IssueStatus.Open if int(assign_to) == -1: issue.AssignTo = creator else: issue.AssignTo = assign_to assign_to=issue.AssignTo issue.Creator = creator issue.CreateDate = datetime.now() issue.LastUpdateDate = datetime.now() session.add(issue) session.commit() session.close() if ENABLE_MAIL_NOTICE: u = userservice.get_user_by_id(assign_to) body = mailservice.render_mail_template('Issue/NoticeAssignTo.html',Subject=subject,Description=description,SystemUrl=HOST) mailservice.send_mail(u.Email, u'指派给您的新问题 ' + subject,body)
def update(task_id,task_name,assign_to,priority,progress,status,effort,description): session = database.get_session() task_name = task_name.strip() task = session.query(Task).filter(Task.TaskId == task_id).one() changeAssignTo = not (task.AssignTo == assign_to) task.TaskName = task_name task.AssignTo = assign_to task.Priority = priority task.Progress = progress task.Status = status task.Description = description task.Effort = task.Effort + float(effort) task.LastUpdateDate = datetime.now() project_id = task.ProjectId session.commit() session.close() calcprogress(project_id) if ENABLE_MAIL_NOTICE and changeAssignTo: u = userservice.get_user_by_id(assign_to) body = mailservice.render_mail_template('Task/NoticeAssignTo.html',TaskName=task_name,Description=description,SystemUrl=HOST) mailservice.send_mail(u.Email, u'指派给您的新任务 ' + task_name,body) return True
def create(project_id,task_name,priority,assign_to,description,creator): session = database.get_session() task_name = task_name.strip() t = Task() t.ProjectId = project_id t.TaskName = task_name t.Priority = priority t.Progress = 0 if assign_to == -1: t.AssignTo = creator else: t.AssignTo = assign_to assign_to = t.AssignTo t.Effort = 0 t.Status = TaskStatus.New t.Description = description t.Creator = creator t.CreateDate = datetime.now() t.LastUpdateDate = datetime.now() session.add(t) session.commit() session.close() calcprogress(project_id) if ENABLE_MAIL_NOTICE: u = userservice.get_user_by_id(assign_to) body = mailservice.render_mail_template('Task/NoticeAssignTo.html',TaskName=task_name,Description=description,SystemUrl=HOST) mailservice.send_mail(u.Email, u'指派给您的新任务 ' + task_name,body)
def remove_member(project_id,user_id): session = database.get_session() session.query(Member).filter(Member.ProjectId == project_id,Member.UserId == user_id).delete() session.commit() session.close() if ENABLE_MAIL_NOTICE: p = projectservice.get(project_id) u = userservice.get_user_by_id(user_id) body = mailservice.render_mail_template('Team/RemoveMember.html',ProjectName=p.ProjectName,SystemUrl=HOST) mailservice.send_mail(u.Email, u'您已经被 ' + p.ProjectName + u' 项目组移除',body)
def update(issue_id,subject,category_id,assign_to,priority,status,feedback,current_user): session = database.get_session() subject = subject.strip() issue = session.query(Issue).filter(Issue.IssueId == issue_id).one() changeAssignTo = not (issue.AssignTo == assign_to) description = issue.Description if (not issue.CategoryId == category_id) or (not issue.Status == status) or (not issue.Priority == priority) or (not issue.AssignTo == assign_to) or (len(feedback) > 0): history = IssueHistory() history.IssueId = issue.IssueId history.RawStatus = issue.Status history.NewStatus = status history.RawPriority = issue.Priority history.NewPriority = priority history.RawAssignTo = issue.AssignTo history.NewAssignTo = assign_to history.RawCategoryId = issue.CategoryId history.NewCategoryId = category_id history.Feedback = feedback history.Creator = current_user history.CreateDate = datetime.now() session.add(history) issue.Subject = subject issue.CategoryId = category_id issue.AssignTo = assign_to issue.Priority = priority issue.Status = status issue.LastUpdateDate = datetime.now() session.commit() session.close() if ENABLE_MAIL_NOTICE and changeAssignTo: u = userservice.get_user_by_id(assign_to) body = mailservice.render_mail_template('Issue/NoticeAssignTo.html',Subject=subject,Description=description,SystemUrl=HOST) mailservice.send_mail(u.Email, u'指派给您的新问题 ' + subject,body) return True