Exemple #1
0
 def put(self, working_file_id):
     comment = self.get_comment_from_args()
     working_file = files_service.get_working_file(working_file_id)
     task = tasks_service.get_task(working_file["task_id"])
     user_service.check_project_access(task["project_id"])
     working_file = self.update_comment(working_file_id, comment)
     return working_file
Exemple #2
0
    def put(self, task_id):
        (person_id, comment, working_file_id) = self.get_arguments()

        try:
            task = tasks_service.get_task(task_id)
            if not permissions.has_manager_permissions():
                user_service.check_assigned(task_id)

            person = persons_service.get_person(person_id)

            preview_path = ""
            if working_file_id is not None:
                working_file = files_service.get_working_file(working_file_id)
                software = files_service.get_software(
                    working_file["software_id"])
                revision = working_file["revision"]

                preview_path = self.get_preview_path(task,
                                                     working_file["name"],
                                                     revision, software)

            task = tasks_service.task_to_review(task["id"], person, comment,
                                                preview_path)
        except PersonNotFoundException:
            return {"error": "Cannot find given person."}, 400

        return task
Exemple #3
0
 def put(self, working_file_id):
     working_file = files_service.get_working_file(working_file_id)
     task = tasks_service.get_task(working_file["task_id"])
     user_service.check_project_access(task["project_id"])
     working_file = files_service.update_working_file(
         working_file_id, {"updated_at": datetime.datetime.utcnow()})
     return working_file
Exemple #4
0
    def post(self, asset_instance_id):
        args = self.get_arguments()

        try:
            revision = int(args["revision"])
            try:
                working_file = files_service.get_working_file(
                    args["working_file_id"]
                )
                working_file_id = working_file["id"]
            except WorkingFileNotFoundException:
                pass
            asset_instance = assets_service.get_asset_instance(
                asset_instance_id
            )

            entity = assets_service.get_asset(asset_instance["asset_id"])
            if not permissions.has_manager_permissions():
                user_service.check_has_task_related(entity["project_id"])

            output_type = files_service.get_output_type(args["output_type_id"])
            task_type = tasks_service.get_task_type(args["task_type_id"])
            if args["person_id"] is None:
                person = persons_service.get_current_user()
            else:
                person = persons_service.get_person(args["person_id"])

            output_file = files_service.create_new_output_revision(
                asset_instance["asset_id"],
                working_file_id,
                output_type["id"],
                person["id"],
                task_type["id"],
                asset_instance_id=asset_instance["id"],
                revision=revision,
                name=args["name"],
                representation=args["representation"],
                comment=args["comment"],
                extension=args["extension"]
            )

            output_file_dict = self.add_path_info(
                output_file,
                "output",
                asset_instance,
                output_type,
                task_type=task_type,
                name=args["name"],
                extension=args["extension"],
                representation=args["representation"],
                separator=args["sep"]
            )
        except OutputTypeNotFoundException:
            return {"message": "Cannot find given output type."}, 400
        except PersonNotFoundException:
            return {"message": "Cannot find given person."}, 400
        except EntryAlreadyExistsException:
            return {"message": "The given output file already exists."}, 400

        return output_file_dict, 201
Exemple #5
0
    def post(self, asset_instance_id, temporal_entity_id):
        args = self.get_arguments()

        try:
            revision = int(args["revision"])
            try:
                working_file = files_service.get_working_file(
                    args["working_file_id"])
                working_file_id = working_file["id"]
            except WorkingFileNotFoundException:
                working_file_id = None

            asset_instance = assets_service.get_asset_instance(
                asset_instance_id)

            entity = assets_service.get_asset(asset_instance["asset_id"])
            user_service.check_project_access(entity["project_id"])

            output_type = files_service.get_output_type(args["output_type_id"])
            task_type = tasks_service.get_task_type(args["task_type_id"])
            if args["person_id"] is None:
                person = persons_service.get_current_user()
            else:
                person = persons_service.get_person(args["person_id"])

            output_file_dict = files_service.create_new_output_revision(
                asset_instance["asset_id"],
                working_file_id,
                output_type["id"],
                person["id"],
                task_type["id"],
                asset_instance_id=asset_instance["id"],
                temporal_entity_id=temporal_entity_id,
                revision=revision,
                name=args["name"],
                path=args["path"],
                render_info=args["render_info"],
                representation=args["representation"],
                comment=args["comment"],
                nb_elements=int(args["nb_elements"]),
                extension=args["extension"],
                file_status_id=args['file_status_id'],
            )

            if args["path"]:
                folder_path, file_name = os.path.split(args["path"])
                output_file_dict.update({
                    "folder_path": folder_path,
                    "file_name": file_name
                })

        except OutputTypeNotFoundException:
            return {"message": "Cannot find given output type."}, 400
        except PersonNotFoundException:
            return {"message": "Cannot find given person."}, 400
        except EntryAlreadyExistsException:
            return {"message": "The given output file already exists."}, 400

        return output_file_dict, 201
Exemple #6
0
    def post(self, entity_id):
        args = self.get_arguments()

        try:
            revision = int(args["revision"])

            try:
                working_file = files_service.get_working_file(
                    args["working_file_id"]
                )
                working_file_id = working_file["id"]
            except WorkingFileNotFoundException:
                working_file_id = None

            entity = entities_service.get_entity(entity_id)
            user_service.check_project_access(entity["project_id"])
            output_type = files_service.get_output_type(args["output_type_id"])
            task_type = tasks_service.get_task_type(args["task_type_id"])

            if args["person_id"] is None:
                person = persons_service.get_current_user()
            else:
                person = persons_service.get_person(args["person_id"])

            output_file = files_service.create_new_output_revision(
                entity_id,
                working_file_id,
                output_type["id"],
                person["id"],
                args["task_type_id"],
                revision=revision,
                name=args["name"],
                comment=args["comment"],
                representation=args["representation"],
                extension=args["extension"],
                nb_elements=int(args["nb_elements"]),
                file_status_id=args['file_status_id'],
            )

            output_file_dict = self.add_path_info(
                output_file,
                "output",
                entity,
                output_type,
                task_type=task_type,
                name=args["name"],
                extension=args["extension"],
                representation=args["representation"],
                separator=args["sep"],
                nb_elements=int(args["nb_elements"]),
            )
        except OutputTypeNotFoundException:
            return {"error": "Cannot find given output type."}, 400
        except PersonNotFoundException:
            return {"error": "Cannot find given person."}, 400
        except EntryAlreadyExistsException:
            return {"error": "The given output file already exists."}, 400

        return output_file_dict, 201
Exemple #7
0
 def test_get_working_file(self):
     working_file = files_service.get_working_file(self.working_file.id)
     self.assertEqual(working_file["id"], str(self.working_file.id))
     self.assertRaises(
         WorkingFileNotFoundException,
         files_service.get_working_file,
         "unknown",
     )
Exemple #8
0
 def put(self, working_file_id):
     comment = self.get_comment_from_args()
     working_file = files_service.get_working_file(working_file_id)
     task = tasks_service.get_task(working_file["task_id"])
     if not permissions.has_manager_permissions():
         user_service.check_has_task_related(task["project_id"])
     working_file = self.update_comment(working_file_id, comment)
     return working_file
Exemple #9
0
 def is_allowed(self, working_file_id):
     working_file = files_service.get_working_file(working_file_id)
     task = tasks_service.get_task(working_file["task_id"])
     try:
         if not permissions.has_manager_permissions():
             user_service.check_has_task_related(task.project_id)
         return True
     except permissions.PermissionDenied:
         return False
Exemple #10
0
 def put(self, working_file_id):
     working_file = files_service.get_working_file(working_file_id)
     task = tasks_service.get_task(working_file["task_id"])
     if not permissions.has_manager_permissions():
         user_service.check_has_task_related(task["project_id"])
     working_file = files_service.update_working_file(
         working_file_id,
         {"updated_at": datetime.datetime.utcnow()}
     )
     return working_file
Exemple #11
0
    def get(self, file_id):
        try:
            file_dict = files_service.get_working_file(file_id)
            task = tasks_service.get_task(file_dict["task_id"])
            project_id = task["project_id"]
        except WorkingFileNotFoundException:
            file_dict = files_service.get_output_file(file_id)
            entity = entities_service.get_entity(file_dict["entity_id"])
            project_id = entity["project_id"]

        user_service.check_project_access(project_id)
        return file_dict
Exemple #12
0
    def get(self, file_id):
        try:
            file_dict = files_service.get_working_file(file_id)
            task = tasks_service.get_task(file_dict["task_id"])
            project_id = task["project_id"]
        except WorkingFileNotFoundException:
            file_dict = files_service.get_output_file(file_id)
            entity = entities_service.get_entity(file_dict["entity_id"])
            project_id = entity["project_id"]

        if not permissions.has_manager_permissions():
            user_service.check_has_task_related(project_id)
        return file_dict
Exemple #13
0
 def check_access(self, working_file_id):
     working_file = files_service.get_working_file(working_file_id)
     task = tasks_service.get_task(working_file["task_id"])
     user_service.check_project_access(task["project_id"])
     user_service.check_entity_access(task["entity_id"])
     return working_file
Exemple #14
0
 def check_read_permissions(self, instance):
     working_file = files_service.get_working_file(instance["id"])
     task = tasks_service.get_task(working_file["task_id"])
     return user_service.check_project_access(task["project_id"])
Exemple #15
0
 def check_update_permissions(self, instance, data):
     working_file = files_service.get_working_file(instance["id"])
     return permissions.has_manager_permissions or \
         user_service.check_assigned(working_file["task_id"])
Exemple #16
0
 def check_update_permissions(self, instance, data):
     working_file = files_service.get_working_file(instance["id"])
     task = tasks_service.get_task(working_file["task_id"])
     user_service.check_project_access(task["project_id"])
Exemple #17
0
 def is_exist(self, working_file_id):
     return files_service.get_working_file(working_file_id) is not None