Esempio n. 1
0
 def post(self, task_type_id):
     permissions.check_manager_permissions()
     criterions = query.get_query_criterions_from_request(request)
     shots = shots_service.get_shots(criterions)
     task_type = tasks_service.get_task_type(task_type_id)
     tasks = [tasks_service.create_task(task_type, shot) for shot in shots]
     return tasks, 201
Esempio n. 2
0
    def get(self):
        args = self.get_args([("after", None, None), ("before", None, None),
                              ("only_files", False, False),
                              ("page_size", 100, False)])
        permissions.check_manager_permissions()
        before = None
        after = None

        try:
            if args["before"] is not None:
                before = fields.get_date_object(args["before"],
                                                "%Y-%m-%dT%H:%M:%S")
            if args["after"] is not None:
                after = fields.get_date_object(args["after"],
                                               "%Y-%m-%dT%H:%M:%S")
        except Exception:
            return {
                "error":
                True,
                "message":
                "Wrong date format for before or after argument."
                "Expected format: 2020-01-05T13:23:10"
            }, 400
        page_size = args["page_size"]
        only_files = args["only_files"] == "true"
        return events_service.get_last_events(after=after,
                                              before=before,
                                              page_size=page_size,
                                              only_files=only_files)
Esempio n. 3
0
 def put(self, shot_id):
     """
     Resource to allow the modification of assets linked to a shot.
     """
     casting = request.json
     permissions.check_manager_permissions()
     return breakdown_service.update_casting(shot_id, casting)
Esempio n. 4
0
 def delete(self, scene_id):
     """
     Delete given scene.
     """
     permissions.check_manager_permissions()
     deleted_scene = shots_service.remove_scene(scene_id)
     return deleted_scene, 204
Esempio n. 5
0
 def get(self):
     args = self.get_args([
         ("after", None, False),
         ("before", None, False),
         ("only_files", False, False),
         ("page_size", 100, False),
         ("project_id", None, False),
     ])
     permissions.check_manager_permissions()
     before = self.parse_date_parameter(args["before"])
     after = self.parse_date_parameter(args["after"])
     page_size = args["page_size"]
     only_files = args["only_files"] == "true"
     project_id = args.get("project_id", None)
     if project_id is not None and not fields.is_valid_id(project_id):
         raise WrongParameterException(
             "The project_id parameter is not a valid id")
     else:
         return events_service.get_last_events(
             after=after,
             before=before,
             page_size=page_size,
             only_files=only_files,
             project_id=project_id,
         )
Esempio n. 6
0
    def post(self, project_id, asset_type_id):
        (name, description, data) = self.get_arguments()

        permissions.check_manager_permissions()
        asset = assets_service.create_asset(project_id, asset_type_id, name,
                                            description, data)
        return asset, 201
Esempio n. 7
0
 def get(self, person_id, date):
     current_user = persons_service.get_current_user()
     if current_user["id"] != person_id:
         permissions.check_manager_permissions()
     try:
         return time_spents_service.get_day_off(person_id, date)
     except WrongDateFormatException:
         abort(404)
Esempio n. 8
0
    def get(self):
        name = request.args.get("name", None)
        try:
            permissions.check_manager_permissions()

            return projects_service.open_projects(name=name)
        except permissions.PermissionDenied:
            return user_service.get_open_projects(name=name)
Esempio n. 9
0
 def post(self, project_id):
     """
     Create an episode for given project.
     """
     name = self.get_arguments()
     projects_service.get_project(project_id)
     permissions.check_manager_permissions()
     return shots_service.create_episode(project_id, name), 201
Esempio n. 10
0
 def post(self, project_id):
     """
     Create a shot for given project.
     """
     (sequence_id, name) = self.get_arguments()
     projects_service.get_project(project_id)
     permissions.check_manager_permissions()
     scene = shots_service.create_scene(project_id, sequence_id, name)
     return scene, 201
Esempio n. 11
0
 def post(self, scene_id):
     """
     Mark given scene as source of given shot.
     """
     args = self.get_args([("shot_id", None, True)])
     permissions.check_manager_permissions()
     scene = shots_service.get_scene(scene_id)
     shot = shots_service.get_shot(args["shot_id"])
     return scenes_service.add_shot_to_scene(scene, shot), 201
Esempio n. 12
0
    def delete(self, shot_id):
        try:
            permissions.check_manager_permissions()
            deleted_shot = shots_service.remove_shot(shot_id)
        except ShotNotFoundException:
            abort(404)
        except permissions.PermissionDenied:
            abort(403)

        return deleted_shot, 204
Esempio n. 13
0
 def get(self):
     args = self.get_args(
         [("before", None, None), ("page_size", 100, False)]
     )
     permissions.check_manager_permissions()
     before = None
     if args["before"] is not None:
         before = fields.get_date_object(args["before"], "%Y-%m-%dT%H:%M:%S")
     page_size = args["page_size"]
     return events_service.get_last_login_logs(before, page_size)
Esempio n. 14
0
    def put(self, task_id):
        (person_id) = self.get_arguments()

        try:
            permissions.check_manager_permissions()
            task = self.assign_task(task_id, person_id)
        except PersonNotFoundException:
            return {"error": "Assignee doesn't exist in database."}, 400

        return task
Esempio n. 15
0
    def get(self):
        args = self.get_args([
            ("after", None, False),
            ("before", None, False),
            ("only_files", False, False),
            ("page_size", 100, False),
            ("project_id", None, False),
        ])
        permissions.check_manager_permissions()
        before = None
        after = None

        if args["before"] is not None:
            try:
                before = fields.get_date_object(
                    args["before"], "%Y-%m-%dT%H:%M:%S"
                )
            except Exception:
                try:
                    before = fields.get_date_object(args["before"], "%Y-%m-%d")
                except Exception:
                    raise WrongParameterException(
                        "Wrong date format for before argument."
                        "Expected format: 2020-01-05T13:23:10 or 2020-01-05"
                    )

        if args["after"] is not None:
            try:
                after = fields.get_date_object(
                    args["after"], "%Y-%m-%dT%H:%M:%S"
                )
            except Exception:
                try:
                    after = fields.get_date_object(args["after"], "%Y-%m-%d")
                except Exception:
                    raise WrongParameterException(
                        "Wrong date format for after argument."
                        "Expected format: 2020-01-05T13:23:10 or 2020-01-05"
                    )

        page_size = args["page_size"]
        only_files = args["only_files"] == "true"
        project_id = args.get("project_id", None)
        if project_id is not None and not fields.is_valid_id(project_id):
            raise WrongParameterException(
                "The project_id parameter is not a valid id"
            )
        else:
            return events_service.get_last_events(
                after=after,
                before=before,
                page_size=page_size,
                only_files=only_files,
                project_id=project_id
            )
Esempio n. 16
0
    def delete(self, asset_id):
        permissions.check_manager_permissions()

        parser = reqparse.RequestParser()
        parser.add_argument("force", default=False, type=bool)
        args = parser.parse_args()
        force = args["force"]
        if force:
            permissions.check_admin_permissions()
        deleted_asset = assets_service.remove_asset(asset_id, force=force)
        return deleted_asset, 204
Esempio n. 17
0
 def post(self, scene_id):
     """
     Create an asset instance on given scene.
     """
     args = self.get_args([("asset_id", None, True),
                           ("description", None, False)])
     scene = shots_service.get_scene(scene_id)
     permissions.check_manager_permissions()
     scene = breakdown_service.add_asset_instance_to_scene(
         scene_id, args["asset_id"], args["description"])
     return scene, 201
Esempio n. 18
0
    def post(self, project_id):
        tree_name = self.get_arguments()

        try:
            permissions.check_manager_permissions()
            tree = file_tree_service.get_tree_from_file(tree_name)
            project = projects_service.update_project(project_id,
                                                      {"file_tree": tree})
        except WrongFileTreeFileException:
            abort(400, "Selected tree is not available")

        return project
Esempio n. 19
0
    def get(self):
        name = request.args.get("name", None)
        try:
            permissions.check_manager_permissions()

            if name is None:
                return projects_service.get_projects()
            else:
                return [projects_service.get_project_by_name(name)]
        except permissions.PermissionDenied:
            if name is None:
                return user_service.get_projects()
            else:
                return [user_service.get_project_by_name(name)]
Esempio n. 20
0
    def delete(self, shot_id):
        """
        Delete given shot.
        """
        try:
            parser = reqparse.RequestParser()
            parser.add_argument("force", default=False, type=bool)
            args = parser.parse_args()
            force = args["force"]

            permissions.check_manager_permissions()
            if force:
                permissions.check_admin_permissions()
            deleted_shot = shots_service.remove_shot(shot_id, force=force)
        except ShotNotFoundException:
            abort(404)
        except permissions.PermissionDenied:
            abort(403)

        return deleted_shot, 204
Esempio n. 21
0
 def check_create_permissions(self, data):
     return permissions.check_manager_permissions()
Esempio n. 22
0
 def get(self, year):
     permissions.check_manager_permissions()
     return time_spents_service.get_week_table(year)
Esempio n. 23
0
 def get(self, person_id, date):
     permissions.check_manager_permissions()
     try:
         return time_spents_service.get_time_spents(person_id, date)
     except WrongDateFormatException:
         abort(404)
Esempio n. 24
0
 def delete(self, scene_id, shot_id):
     permissions.check_manager_permissions()
     scene = shots_service.get_scene(scene_id)
     shot = shots_service.get_shot(shot_id)
     return scenes_service.remove_shot_from_scene(scene, shot), 204
Esempio n. 25
0
 def check_read_permissions(self, instance):
     return permissions.check_manager_permissions()
Esempio n. 26
0
 def check_delete_permissions(self, instance):
     return permissions.check_manager_permissions()
Esempio n. 27
0
 def check_update_permissions(self, instance, data):
     return permissions.check_manager_permissions()
Esempio n. 28
0
 def delete(self, asset_id):
     permissions.check_manager_permissions()
     deleted_asset = assets_service.remove_asset(asset_id)
     return deleted_asset, 204
Esempio n. 29
0
 def check_permissions(self):
     return permissions.check_manager_permissions()
Esempio n. 30
0
 def put(self, entity_id, preview_file_id):
     permissions.check_manager_permissions()
     return entities_service.update_entity_preview(entity_id,
                                                   preview_file_id)