コード例 #1
0
ファイル: resources.py プロジェクト: dsparrow27/zou
 def get(self, task_id):
     task = tasks_service.get_task(task_id)
     user_service.check_project_access(task["project_id"])
     user_service.check_entity_access(task["entity_id"])
     is_client = permissions.has_client_permissions()
     is_manager = permissions.has_manager_permissions()
     return tasks_service.get_comments(task_id, is_client, is_manager)
コード例 #2
0
    def post(self, task_id, comment_id):
        """
        Add a preview to given task.
        ---
        tags:
        - Tasks
        description: "Revision is automatically set: it is equal to last revision + 1."
        parameters:
          - in: path
            name: task_id
            required: True
            schema:
                type: UUID
                example: a24a6ea4-ce75-4665-a070-57453082c25
          - in: path
            name: comment_id
            required: True
            schema:
                type: UUID
                example: a24a6ea4-ce75-4665-a070-57453082c25
        responses:
            201:
                description: Preview added to given task
        """
        task = tasks_service.get_task(task_id)
        user_service.check_project_access(task["project_id"])
        user_service.check_entity_access(task["entity_id"])

        comment = tasks_service.get_comment(comment_id)
        tasks_service.get_task_status(comment["task_status_id"])
        person = persons_service.get_current_user()
        preview_file = tasks_service.add_preview_file_to_comment(
            comment_id, person["id"], task_id)
        return preview_file, 201
コード例 #3
0
    def post(self, task_id):
        (
            name,
            mode,
            software_id,
            comment,
            revision,
            separator,
        ) = self.get_arguments()

        try:
            task = tasks_service.get_task(task_id)
            user_service.check_project_access(task["project_id"])
            user_service.check_entity_access(task["entity_id"])

            software = files_service.get_software(software_id)
            is_revision_set_by_user = revision != 0
            if not is_revision_set_by_user:
                revision = files_service.get_next_working_file_revision(
                    task_id, name
                )
            file_path = file_tree_service.get_working_folder_path(
                task, mode=mode, software=software, name=name, sep=separator,
                revision=revision
            )
            file_name = file_tree_service.get_working_file_name(
                task, mode=mode, revision=revision, software=software, name=name
            )
        except MalformedFileTreeException as exception:
            return (
                {"message": str(exception), "received_data": request.json},
                400,
            )

        return {"path": file_path, "name": file_name}, 200
コード例 #4
0
 def get(self, scene_id):
     """
     Retrieve all tasks related to a given scene.
     """
     scene = shots_service.get_scene(scene_id)
     user_service.check_entity_access(scene["id"])
     return tasks_service.get_tasks_for_scene(scene_id)
コード例 #5
0
 def get(self, task_id):
     """
     Return comments linked to given task.
     ---
     tags:
     - Tasks
     parameters:
       - in: path
         name: task_id
         required: True
         schema:
             type: UUID
             example: a24a6ea4-ce75-4665-a070-57453082c25
     responses:
         200:
             description: Comments linked to given task
     """
     task = tasks_service.get_task(task_id)
     user_service.check_project_access(task["project_id"])
     user_service.check_entity_access(task["entity_id"])
     is_client = permissions.has_client_permissions()
     is_manager = permissions.has_manager_permissions()
     is_supervisor = permissions.has_supervisor_permissions()
     return tasks_service.get_comments(task_id, is_client, is_manager
                                       or is_supervisor)
コード例 #6
0
 def get(self, task_id, date):
     """
     Get time spent on a given task by a given person.
     ---
     tags:
     - Tasks
     parameters:
       - in: path
         name: task_id
         required: True
         schema:
             type: UUID
             example: a24a6ea4-ce75-4665-a070-57453082c25
       - in: path
         name: date
         required: True
         schema:
             type: timestamp
             example: 2022-07-12
     responses:
         200:
             description: Time spent on given task by given person
         404:
             description: Wrong date format
     """
     try:
         task = tasks_service.get_task(task_id)
         user_service.check_project_access(task["project_id"])
         user_service.check_entity_access(task["entity_id"])
         return tasks_service.get_time_spents(task_id)
     except WrongDateFormatException:
         abort(404)
コード例 #7
0
 def put(self, preview_file_id):
     preview_file = files_service.get_preview_file(preview_file_id)
     task = tasks_service.get_task(preview_file["task_id"])
     user_service.check_project_access(task["project_id"])
     user_service.check_entity_access(task["entity_id"])
     return entities_service.update_entity_preview(task["entity_id"],
                                                   preview_file_id)
コード例 #8
0
ファイル: attachment_file.py プロジェクト: unit-image/zou
 def check_read_permissions(self, instance):
     attachment_file = instance
     comment = tasks_service.get_comment(attachment_file["comment_id"])
     task = tasks_service.get_task(comment["object_id"])
     user_service.check_project_access(task["project_id"])
     user_service.check_entity_access(task["entity_id"])
     return True
コード例 #9
0
    def post(self, entity_id):
        (name, path, mode, description, comment, person_id, software_id,
         revision, sep, size) = self.get_arguments()
        task_id = None

        # try by task
        try:
            task = tasks_service.get_task(entity_id)
            task_id = entity_id
            entity_id = task["entity_id"]
            user_service.check_project_access(task["project_id"])
            user_service.check_entity_access(task["entity_id"])
            tasks_service.assign_task(task_id,
                                      persons_service.get_current_user()["id"])
        except:
            # try by entity
            entity = entities_service.get_entity(entity_id)
            user_service.check_project_access(entity["project_id"])
            user_service.check_entity_access(entity_id)

        try:
            working_file = files_service.create_new_working_revision(
                person_id,
                software_id,
                task_id=task_id,
                entity_id=entity_id,
                name=name,
                path=path,
                comment=comment,
                revision=revision,
            )
        except EntryAlreadyExistsException:
            return {"error": "The given working file already exists."}, 400

        return working_file, 201
コード例 #10
0
 def get(self, scene_id):
     """
     Retrieve all shots that comes from given scene.
     """
     scene = shots_service.get_scene(scene_id)
     user_service.check_entity_access(scene["id"])
     return scenes_service.get_shots_by_scene(scene_id)
コード例 #11
0
    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
コード例 #12
0
ファイル: resources.py プロジェクト: dsparrow27/zou
    def put(self, task_id):
        (
            person_id,
            comment,
            name,
            revision,
            change_status,
        ) = self.get_arguments()

        try:
            task = tasks_service.get_task(task_id)
            user_service.check_project_access(task["project_id"])
            user_service.check_entity_access(task["project_id"])

            if person_id is not None:
                person = persons_service.get_person(person_id)
            else:
                person = persons_service.get_current_user()

            preview_path = self.get_preview_path(task, name, revision)

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

        return task
コード例 #13
0
 def get(self, shot_id):
     """
     Retrieve all task types related to a given shot.
     """
     shot = shots_service.get_shot(shot_id)
     user_service.check_project_access(shot["project_id"])
     user_service.check_entity_access(shot["id"])
     return tasks_service.get_task_types_for_shot(shot_id)
コード例 #14
0
 def get(self, shot_id):
     """
     Retrieve all assets for a given shot.
     """
     shot = shots_service.get_shot(shot_id)
     user_service.check_project_access(shot["project_id"])
     user_service.check_entity_access(shot["id"])
     return breakdown_service.get_entity_casting(shot_id)
コード例 #15
0
ファイル: asset_instance.py プロジェクト: withgame/zou
 def check_update_permissions(self, asset_instance, data):
     if permissions.has_admin_permissions():
         return True
     else:
         asset = assets_service.get_asset(asset_instance["asset_id"])
         user_service.check_project_access(asset["project_id"])
         user_service.check_entity_access(asset["id"])
         return True
コード例 #16
0
 def post(self, task_id, comment_id):
     args = self.get_args([
         ("text", "", False),
     ])
     task = tasks_service.get_task(task_id)
     user_service.check_project_access(task["project_id"])
     user_service.check_entity_access(task["entity_id"])
     return comments_service.reply_comment(comment_id, args["text"])
コード例 #17
0
ファイル: resources.py プロジェクト: cgwire/zou
 def get(self, edit_id):
     """
     Retrieve all task types related to a given edit.
     """
     edit = edits_service.get_edit(edit_id)
     user_service.check_project_access(edit["project_id"])
     user_service.check_entity_access(edit["id"])
     return tasks_service.get_task_types_for_edit(edit_id)
コード例 #18
0
ファイル: resources.py プロジェクト: withgame/zou
 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"])
     user_service.check_entity_access(task["entity_id"])
     working_file = self.update_comment(working_file_id, comment)
     return working_file
コード例 #19
0
 def get(self, scene_id):
     """
     Retrieve given scene.
     """
     scene = shots_service.get_full_scene(scene_id)
     user_service.check_project_access(scene["project_id"])
     user_service.check_entity_access(scene["id"])
     return scene
コード例 #20
0
ファイル: resources.py プロジェクト: withgame/zou
    def get(self, task_id):
        result = {}
        task = tasks_service.get_task(task_id)
        user_service.check_project_access(task["project_id"])
        user_service.check_entity_access(task["entity_id"])
        result = files_service.get_working_files_for_task(task["id"])

        return result
コード例 #21
0
ファイル: resources.py プロジェクト: withgame/zou
 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"])
     user_service.check_entity_access(task["entity_id"])
     working_file = files_service.update_working_file(
         working_file_id, {"updated_at": datetime.datetime.utcnow()})
     return working_file
コード例 #22
0
ファイル: resources.py プロジェクト: dsparrow27/zou
 def get(self, task_id, date):
     try:
         task = tasks_service.get_task(task_id)
         user_service.check_project_access(task["project_id"])
         user_service.check_entity_access(task["entity_id"])
         return tasks_service.get_time_spents(task_id)
     except WrongDateFormatException:
         abort(404)
コード例 #23
0
ファイル: resources.py プロジェクト: withgame/zou
 def get(self, asset_id):
     """
     Resource to retrieve the casting of a given asset.
     """
     asset = assets_service.get_asset(asset_id)
     user_service.check_project_access(asset["project_id"])
     user_service.check_entity_access(asset["id"])
     return breakdown_service.get_cast_in(asset_id)
コード例 #24
0
ファイル: resources.py プロジェクト: withgame/zou
 def get(self, asset_id):
     """
     Retrieve given asset.
     """
     asset = assets_service.get_full_asset(asset_id)
     user_service.check_project_access(asset["project_id"])
     user_service.check_entity_access(asset["id"])
     return asset
コード例 #25
0
ファイル: resources.py プロジェクト: withgame/zou
 def get(self, asset_id):
     """
     Retrieve all assets for a given asset.
     """
     asset = assets_service.get_asset(asset_id)
     user_service.check_project_access(asset["project_id"])
     user_service.check_entity_access(asset_id)
     return breakdown_service.get_entity_casting(asset_id)
コード例 #26
0
 def delete(self, task_id, comment_id, reply_id):
     task = tasks_service.get_task(task_id)
     user_service.check_project_access(task["project_id"])
     user_service.check_entity_access(task["entity_id"])
     reply = comments_service.get_reply(comment_id, reply_id)
     current_user = persons_service.get_current_user()
     if reply["person_id"] != current_user["id"]:
         permissions.check_admin_permissions()
     return comments_service.delete_reply(comment_id, reply_id)
コード例 #27
0
 def is_allowed(self, preview_file_id):
     preview_file = files_service.get_preview_file(preview_file_id)
     task = tasks_service.get_task(preview_file["task_id"])
     try:
         user_service.check_project_access(task["project_id"])
         user_service.check_entity_access(task["entity_id"])
         return True
     except permissions.PermissionDenied:
         return False
コード例 #28
0
ファイル: resources.py プロジェクト: ninglesby/zou
 def put(self, preview_file_id):
     annotations = request.json["annotations"]
     preview_file = files_service.get_preview_file(preview_file_id)
     task = tasks_service.get_task(preview_file["task_id"])
     user_service.check_manager_project_access(task["project_id"])
     user_service.check_entity_access(task["entity_id"])
     return preview_files_service.update_preview_file_annotations(
         task["project_id"], preview_file_id, annotations
     )
コード例 #29
0
ファイル: asset_instance.py プロジェクト: withgame/zou
 def check_read_permissions(self, instance):
     if permissions.has_admin_permissions():
         return True
     else:
         asset_instance = self.get_model_or_404(instance["id"])
         asset = assets_service.get_asset(asset_instance.asset_id)
         user_service.check_project_access(asset["project_id"])
         user_service.check_entity_access(asset["id"])
         return True
コード例 #30
0
    def post(self, task_id, date, person_id):
        """
        Set time spent by a person on a task for a given day.
        ---
        tags:
        - Tasks
        parameters:
          - in: path
            name: task_id
            required: True
            schema:
                type: UUID
                example: a24a6ea4-ce75-4665-a070-57453082c25
          - in: path
            name: date
            required: True
            schema:
                type: timestamp
                example: 2022-07-12
          - in: path
            name: person_id
            required: True
            schema:
                type: UUID
                example: a24a6ea4-ce75-4665-a070-57453082c25
          - in: body
            name: Duration
            schema:
                type: object
                properties:
                    duration:
                        type: integer
        responses:
            201:
                description: Time spent by given person on given task for given day is set
            404:
                description: Wrong date format
        """
        args = self.get_arguments()

        try:
            task = tasks_service.get_task(task_id)
            user_service.check_project_access(task["project_id"])
            user_service.check_entity_access(task["entity_id"])
            persons_service.get_person(person_id)
            time_spent = tasks_service.create_or_update_time_spent(
                task_id,
                person_id,
                datetime.datetime.strptime(date, "%Y-%m-%d"),
                args["duration"],
            )
            return time_spent, 201
        except ValueError:
            abort(404)
        except WrongDateFormatException:
            abort(404)