def add_retakes(self, task_id, nb_retakes): for i in range(nb_retakes): comments_service.create_comment( self.person_id, task_id, self.wip_id, "", [], {}, None ) comments_service.create_comment( self.person_id, task_id, self.retake_id, "", [], {}, None )
def test_status_automation_to_ready_for(self): comments_service.create_comment( self.person.id, self.task_modeling.id, str(self.task_status_done.id), "Test", [], {}, None, ) self.assertEqual(self.asset.ready_for, self.task_type_layout.id)
def generate_fixture_shot_and_task(self, shot_name, layout_retakes=0, animation_retakes=0): shot = self.generate_fixture_shot(shot_name, 10) self.generate_fixture_task(entity_id=shot.id, task_type_id=self.task_type_layout.id) self.add_retakes(str(self.task.id), layout_retakes) self.generate_fixture_task(entity_id=shot.id, task_type_id=self.task_type_animation.id) self.add_retakes(str(self.task.id), animation_retakes) comments_service.create_comment(self.person_id, str(self.task.id), self.done_id, "", [], {}, None)
def test_status_automation_to_status(self): wip_status = tasks_service.get_or_create_status( "Work In Progress", "wip", "#3273dc") comments_service.create_comment( self.person.id, self.task_concept.id, str(self.task_status_done.id), "Test", [], {}, None, ) self.assertEqual(str(self.task_modeling.task_status_id), wip_status["id"])
def post(self, task_id): ( task_status_id, comment, person_id, created_at, checklist, ) = self.get_arguments() task = tasks_service.get_task(task_id) user_service.check_project_access(task["project_id"]) user_service.check_entity_access(task["entity_id"]) files = request.files if not permissions.has_manager_permissions(): person_id = None created_at = None comment = comments_service.create_comment( person_id, task_id, task_status_id, comment, checklist, files, created_at, ) return comment, 201
def create_and_update_tasks(self, tasks_update, entity, asset_creation=False): if tasks_update: tasks_map = {} if asset_creation: task_type_ids = self.get_task_types_for_asset_type( entity.entity_type_id) for task_type_id in task_type_ids: task = tasks_service.create_task({"id": task_type_id}, entity.serialize()) tasks_map[task_type_id] = task else: for task in tasks_service.get_tasks_for_asset(str(entity.id)): tasks_map[task["task_type_id"]] = task for task_update in tasks_update: if task_update["task_type_id"] not in tasks_map: task = tasks_service.create_task( tasks_service.get_task_type( task_update["task_type_id"]), entity.serialize(), ) tasks_map[task_update["task_type_id"]] = task task = tasks_map[task_update["task_type_id"]] if (task_update["comment"] is not None or task_update["task_status_id"] != task["task_status_id"]): try: comments_service.create_comment( self.current_user_id, task["id"], task_update["task_status_id"] or task["task_status_id"], task_update["comment"] or "", [], {}, "", ) except WrongParameterException: pass elif asset_creation: self.created_assets.append(entity.serialize())
def create_and_update_tasks( self, tasks_update, entity, shot_creation=False ): if tasks_update: if shot_creation: tasks_map = { str(task_type.id): create_task( task_type.serialize(), entity.serialize() ) for task_type in self.task_types_in_project_for_shots } else: tasks_map = { task["task_type_id"]: task for task in get_tasks_for_shot(str(entity.id)) } for task_update in tasks_update: if task_update["task_type_id"] not in tasks_map: tasks_map[task_update["task_type_id"]] = create_task( get_task_type(task_update["task_type_id"]), entity.serialize(), ) task = tasks_map[task_update["task_type_id"]] if ( task_update["comment"] is not None or task_update["task_status_id"] != task["task_status_id"] ): try: create_comment( self.current_user_id, task["id"], task_update["task_status_id"] or task["task_status_id"], task_update["comment"] or "", [], {}, "", ) except WrongParameterException: pass elif shot_creation: self.created_shots.append(entity.serialize())
def test_get_last_notifications(self): from zou.app import app with app.app_context(): persons_service.get_current_user = self.get_current_user_artist self.generate_fixture_user_cg_artist() self.log_in_cg_artist() person_id = self.user_cg_artist["id"] projects_service.add_team_member(self.project_id, person_id) tasks_service.assign_task(self.task_id, person_id) notifications = user_service.get_last_notifications() self.assertEqual(len(notifications), 0) comments_service.create_comment( self.user["id"], self.task_id, self.to_review_status_id, "Lets go", [], {}, None, ) notifications = user_service.get_last_notifications() self.assertEqual(len(notifications), 1) comments_service.create_comment( self.user_client["id"], self.task_id, self.to_review_status_id, "Wrong picture", [], {}, None, ) notifications = user_service.get_last_notifications() self.assertEqual(len(notifications), 2) self.assertEqual(len(notifications[0]["comment_text"]), 0) self.assertGreater(len(notifications[1]["comment_text"]), 0)
def post(self, project_id): comments = request.json person_id = persons_service.get_current_user()["id"] try: user_service.check_manager_project_access(project_id) except permissions.PermissionDenied: comments = self.get_allowed_comments_only(comments, person_id) result = [] for comment in comments: try: comment = comments_service.create_comment( person_id, comment["object_id"], comment["task_status_id"], comment["comment"], [], {}, None) result.append(comment) except KeyError: pass return result, 201
def post(self, project_id): comments = request.json user_service.check_manager_project_access(project_id) person_id = persons_service.get_current_user()["id"] result = [] for comment in comments: comment = comments_service.create_comment( person_id, comment["object_id"], comment["task_status_id"], comment["comment"], [], {}, None ) result.append(comment) return result, 201