def update_project(self, project_id): if project_id is not None: project = Project.objects.get(id=project_id) if project: # 验收成功 project.receive_status = BusinessPublic.GetProjectStatusObjectByKey('checked') project.save() # 商务人员以及项目经理积分及米值分配 projectpoints = ProjectPoints.objects.filter(project_id=project_id, task__isnull=True, is_created=0) if projectpoints: for projectpoint in projectpoints: if projectpoint: self.create_user_points(None, projectpoint.user.id, projectpoint.points, 1, 1, projectpoint.type) project_points = ProjectPoints.objects.get(id=projectpoint.id) project_points.is_created = 1 project_points.save() # 任务负责人积分及米值分配 taskpoints = Task.objects.filter(project_id=project_id, is_active=1) if taskpoints: for taskpoint in taskpoints: if taskpoint: self.create_user_points(taskpoint.task.id, taskpoint.receiver.id, taskpoint.points, 1, 1, 1) BusinessPublic.create_message(project.auditor_id, project.receiver_id, menu_id=2, messages='恭喜,你的项目已验收通过!')
def before_update(self, request, kwargs): receiver_id = request.data.get('receiver', None) project_id = request.data.get('project', None) if project_id is None: raise Exception('项目 id 不能为空!') if receiver_id is not None: task_id = str(kwargs['pk']) task = Task.objects.get(id=task_id) # 如果当前任务已经存在负责人 if task.receiver: if receiver_id != task.receiver.id: if task.receive_status.id == TaskStatus.objects.get( key='accepted').id: BusinessPublic.create_message( task.sender.id, task.receiver.id, menu_id=2, messages='该任务已被项目负责人移走了!') request.data['is_published'] = 0 request.data[ 'receive_status'] = BusinessPublic.GetTaskStatusIdByKey( 'assigned') else: request.data[ 'receive_status'] = BusinessPublic.GetTaskStatusIdByKey( 'assigned') else: request.data[ 'receive_status'] = BusinessPublic.GetTaskStatusIdByKey( 'unassigned')
def update_project(self, project_id): project = Project.objects.get(id=project_id) if project: # 项目负责人已接手,项目正式开始 project.receive_status = BusinessPublic.GetProjectStatusObjectByKey('accepted') project.save() BusinessPublic.create_message(project.receiver_id, project.sender_id, menu_id=2, messages='项目负责人已接手!')
def update_project(self, project_id): if project_id is not None: project = Project.objects.get(id=project_id) if project: # 验收提交 project.receive_status = BusinessPublic.GetProjectStatusObjectByKey('wait_check') project.save() BusinessPublic.create_message(project.receiver.id, project.auditor.id, menu_id=2, messages='该项目已完成,等待你的验收,请尽快处理!')
def update_project(self, project_id, reason): project = Project.objects.get(id=project_id) if project: # 驳回 project.audit_status = 3 project.save() BusinessPublic.create_reason(project.id, project.auditor.id, project.sender.id, BusinessPublic.GetReasonTypeIdByKey('project_audit_reject'), reason) BusinessPublic.create_message(project.auditor.id, project.sender.id, menu_id=2, messages='你的项目已被驳回,请尽快处理!')
def update_project(self, project_id, reason): project = Project.objects.get(id=project_id) if project is not None: # 拒接 project.receive_status = BusinessPublic.GetProjectStatusObjectByKey('rejected') project.save() reason_type_id = BusinessPublic.GetReasonTypeIdByKey('project_reject') BusinessPublic.create_reason(project.id, project.receiver.id, project.sender.id, reason_type_id, reason) BusinessPublic.create_message(project.receiver.id, project.sender.id, menu_id=2, messages='项目负责人拒接了你的项目,请尽快处理!')
def before_create(self, request): # 将当前登录用户作为项目创建人 request.data['sender'] = request.user.id receiver_id = request.data.get('receiver', None) # 如果存在项目负责人,则将项目接收状态置为 '待接手' if receiver_id is not None: BusinessPublic.create_message(request.user.id, receiver_id, menu_id=2, messages='你有新的项目等待接手!') request.data['receive_status'] = ProjectStatus.objects.get(key='wait_accept').id # 如果不存在项目负责人,则将项目接手状态置为 '未指派项目负责人' else: request.data['receive_status'] = ProjectStatus.objects.get(key='unassigned').id
def update_task(self, task_id): if task_id is not None: from business.models.task import Task task = Task.objects.get(id=task_id) if task is not None: task.receive_status = BusinessPublic.GetTaskStatusObjectByKey( 'wait_check') task.save() BusinessPublic.create_message(task.receiver.id, task.sender.id, menu_id=2, messages='有新的任务需要你的验收,请尽快处理!')
def update_project(self, project_id, reason): if project_id is not None: project = Project.objects.get(id=project_id) if project: # 验收不通过 project.receive_status = BusinessPublic.GetProjectStatusObjectByKey('check_rejected') project.save() BusinessPublic.create_reason(project.id, project.receiver.id, project.auditor.id, BusinessPublic.GetReasonTypeIdByKey('project_check_reject'), reason) BusinessPublic.create_message(project.receiver.id, project.auditor.id, menu_id=2, messages='你的项目验收不通过,请尽快检查!')
def update_task(self, task_id): if task_id is not None: from business.models.task import Task task = Task.objects.get(id=task_id) if task is not None: # 任务负责人已拒接手 task.receive_status = BusinessPublic.GetTaskStatusObjectByKey( 'rejected') task.save() BusinessPublic.create_message(task.receiver.id, task.sender.id, menu_id=2, messages='任务负责人已拒接!')
def post(self, request, format=None): try: project_id = request.data.get('project_id') auditor_id = request.data.get('auditor_id') if project_id is not None and auditor_id is not None: self.update_project(project_id, auditor_id) user_id = request.user.id BusinessPublic.create_message(user_id, auditor_id, menu_id=2, messages='有新的项目需要你的审核,请尽快处理!') except Exception as e: return MykeyResponse(status=status.HTTP_400_BAD_REQUEST, msg='请求失败') return MykeyResponse(status=status.HTTP_200_OK, msg='请求成功')
def update_project(self, project_ids): if len(project_ids) > 0: for project_id in project_ids: project = Project.objects.get(id=project_id) if project.receiver is None: raise Exception('未填写项目负责人!') # 已审核 project.audit_status = 2 project.save() BusinessPublic.create_message( project.auditor.id, project.receiver.id, menu_id=2, messages='项目已通过审核!' )
def update_task(self, request, task_id, task_design_type_id): if task_id is not None and task_design_type_id is not None: task = Task.objects.get(id=task_id) if task is not None: # 任务负责人已接手,任务执行中 task.receive_status = TaskStatus.objects.get(key='accepted') if task.receiver is None: task.receiver = request.user task.task_design_type = TaskDesignType.objects.get( id=task_design_type_id) task.save() self.create_step(task_id, task_design_type_id, request.user) BusinessPublic.create_message(task.receiver.id, task.sender.id, menu_id=2, messages='任务负责人已接手,任务执行中!')
def update_task(self, task_id, reason): if task_id is not None: from business.models.task import Task task = Task.objects.get(id=task_id) if task is not None: # 任务验收不通过 task.receive_status = BusinessPublic.GetTaskStatusObjectByKey( 'check_rejected') task.save() BusinessPublic.create_reason( task.id, task.receiver.id, task.sender.id, BusinessPublic.GetReasonTypeIdByKey('task_check_reject'), reason) BusinessPublic.create_message(task.receiver.id, task.sender.id, menu_id=2, messages='任务验收不通过')
def update_task(self, task_id): if task_id is not None: task = Task.objects.filter(id=task_id, is_published=0).first() if task: task.is_published = 1 task.publish_time = datetime.datetime.now().strftime( '%Y-%m-%d %H:%M:%S') task.receive_status = BusinessPublic.GetTaskStatusObjectByKey( 'wait_accept') task.save() if task.receiver: # 新增消息 BusinessPublic.create_message(task.sender.id, task.receiver.id, menu_id=2, messages='已安排新的任务,请查看!')
def update_task(self, task_id, assessment_id, comments): if task_id is not None: if assessment_id is not None and comments is not None: assessment = TaskAssessment.objects.get(id=assessment_id) task = Task.objects.get(id=task_id) if task is not None: # 任务已通过验收 task.receive_status = BusinessPublic.GetTaskStatusObjectByKey( 'checked') task.task_assessment = assessment task.comments = comments task.save() project_id = task.project_id BusinessPublic.update_progress_by_project_id(project_id) BusinessPublic.create_message(task.sender.id, task.receiver.id, menu_id=2, messages='任务已通过验收!')
def update_task(self, request, task_ids, receiver_id): if len(task_ids) > 0: for task_id in task_ids: from business.models.task import Task task = Task.objects.get(id=task_id) if task is not None: old_receiver_id = task.receiver.id receiver = UserProfile.objects.get(id=receiver_id) task.receiver = receiver task.superior_id = request.user.id task.receive_status = BusinessPublic.GetTaskStatusObjectByKey( 'wait_accept') task.save() if old_receiver_id != receiver_id: # 转移积分 ProjectPoints.objects.filter( user_id=task.receiver.id, is_created=0, project_id=task.project.id).update( user_id=receiver_id) BusinessPublic.create_message(task.superior.id, task.receiver.id, menu_id=2, messages='已安排新的任务,请查看!')
def before_update(self, request, kwargs): project_id = str(kwargs['pk']) receiver_id = request.data.get('receiver', None) if receiver_id is not None and receiver_id != '': if project_id is not None: project = Project.objects.get(id=project_id) if project.receiver: # 如果是驳回状态,需要重新发送消息 if receiver_id == str(project.receiver.id) and project.receive_status.id == 5: # 新增消息 BusinessPublic.create_message(request.user.id, receiver_id, menu_id=2, messages='你有新的项目等待接手!') elif receiver_id != str(project.receiver.id): # 新增消息 BusinessPublic.create_message(request.user.id, receiver_id, menu_id=2, messages='你有新的项目等待接手!') else: BusinessPublic.create_message(request.user.id, receiver_id, menu_id=2, messages='你有新的项目等待接手!') request.data['receive_status'] = ProjectStatus.objects.get(key='wait_accept').id else: request.data['receive_status'] = ProjectStatus.objects.get(key='unassigned').id