示例#1
0
 def get(self, person_id):
     permissions.check_admin_permissions()
     persons_service.invite_person(person_id)
     return {
         "success": True,
         "message": "Email sent"
     }
示例#2
0
 def get(self, person_id, year):
     """
     Return all day off recorded for given year and person.
     ---
     tags:
     - Persons
     parameters:
       - in: path
         name: person_id
         required: True
         schema:
             type: UUID
             example: a24a6ea4-ce75-4665-a070-57453082c25
       - in: path
         name: year
         required: True
         schema:
             type: integer
             example: 2022
     responses:
         200:
             description: All day off recorded for given year and person
     """
     user_id = persons_service.get_current_user()["id"]
     if person_id != user_id:
         permissions.check_admin_permissions()
     return time_spents_service.get_person_day_offs_for_year(
         person_id, year
     )
示例#3
0
文件: resources.py 项目: tpolson/zou
 def get(self, person_id, year, month):
     user_id = persons_service.get_current_user()["id"]
     if person_id != user_id:
         permissions.check_admin_permissions()
     return time_spents_service.get_person_day_offs_for_month(
         person_id, year, month
     )
示例#4
0
 def get(self, person_id, task_type_id):
     """
     For all entities assigned to given person (that have at least one task assigned to given person), returns all tasks for given task type.
     ---
     tags:
     - Tasks
     parameters:
       - in: path
         name: person_id
         required: True
         schema:
             type: UUID
             example: a24a6ea4-ce75-4665-a070-57453082c25
       - in: path
         name: task_type_id
         required: True
         schema:
             type: UUID
             example: a24a6ea4-ce75-4665-a070-57453082c25
     responses:
         200:
             description: All Tasks for given task type
     """
     user = persons_service.get_current_user()
     if person_id != user["id"]:
         permissions.check_admin_permissions()
     return tasks_service.get_person_related_tasks(person_id, task_type_id)
示例#5
0
 def get(self, project_id):
     permissions.check_admin_permissions()
     projects_service.get_project(project_id)
     page = self.get_page()
     return notifications_service.get_notifications_for_project(
         project_id, page
     )
示例#6
0
 def delete(self, person_id, department_id):
     """
     Remove a user from given department.
     ---
     tags:
     - Persons
     parameters:
       - in: path
         name: person_id
         required: True
         schema:
             type: UUID
             example: a24a6ea4-ce75-4665-a070-57453082c25
       - in: path
         name: department_id
         required: True
         schema:
             type: UUID
             example: a24a6ea4-ce75-4665-a070-57453082c25
     responses:
         204:
             description: User removed from given department
     """
     permissions.check_admin_permissions()
     try:
         department = tasks_service.get_department(department_id)
     except DepartmentNotFoundException:
         raise WrongParameterException(
             "Department ID matches no department"
         )
     persons_service.remove_from_department(department_id, person_id)
     return "", 204
示例#7
0
    def post(self, project_id):
        args = self.get_args(
            [
                ("entity_type", "Asset", False),
                ("name", "", True),
                ("for_client", "False", False),
                ("choices", [], False, "append"),
            ]
        )
        permissions.check_admin_permissions()

        args["for_client"] = args["for_client"] == "True"

        if args["entity_type"] not in ["Asset", "Shot"]:
            raise WrongParameterException(
                "Wrong entity type. Please select Asset or Shot."
            )

        if len(args["name"]) == 0:
            raise WrongParameterException("Name cannot be empty.")

        return (
            projects_service.add_metadata_descriptor(
                project_id,
                args["entity_type"],
                args["name"],
                args["choices"],
                args["for_client"]
            ),
            201,
        )
示例#8
0
 def get(self):
     name = request.args.get("name", None)
     try:
         permissions.check_admin_permissions()
         return projects_service.open_projects(name=name)
     except permissions.PermissionDenied:
         return user_service.get_open_projects(name=name)
示例#9
0
文件: resources.py 项目: withgame/zou
 def get(self, person_id, year, month, day):
     permissions.check_admin_permissions()
     try:
         return time_spents_service.get_day_time_spents(
             person_id, year, month, day)
     except WrongDateFormatException:
         abort(404)
示例#10
0
 def post(self, person_id):
     """
     Add a user to given department.
     ---
     tags:
     - Persons
     parameters:
       - in: path
         name: person_id
         required: True
         schema:
             type: UUID
             example: a24a6ea4-ce75-4665-a070-57453082c25
     responses:
         201:
             description: User added to given department
     """
     permissions.check_admin_permissions()
     args = self.get_args(
         [
             ("department_id", None, True),
         ]
     )
     try:
         department = tasks_service.get_department(args["department_id"])
     except DepartmentNotFoundException:
         raise WrongParameterException(
             "Department ID matches no department"
         )
     person = persons_service.add_to_department(department["id"], person_id)
     return person, 201
示例#11
0
 def delete(self, project_id, task_type_id):
     """
     Delete all tasks for a given task type and project.
     ---
     tags:
     - Tasks
     description: It's mainly used when tasks are created by mistake at the beginning of the project.
     parameters:
       - in: path
         name: project_id
         required: True
         schema:
             type: UUID
             example: a24a6ea4-ce75-4665-a070-57453082c25
       - in: path
         name: task_type_id
         required: True
         schema:
             type: UUID
             example: a24a6ea4-ce75-4665-a070-57453082c25
     responses:
         204:
             description: All tasks for given task type and project deleted
     """
     permissions.check_admin_permissions()
     projects_service.get_project(project_id)
     task_ids = deletion_service.remove_tasks_for_project_and_task_type(
         project_id, task_type_id)
     for task_id in task_ids:
         tasks_service.clear_task_cache(task_id)
     return "", 204
示例#12
0
文件: resources.py 项目: mmasjedi/zou
 def get(self, project_id):
     """
     Retrieve all entity links related to given project.
     It's mainly used for synchronisation purpose.
     """
     permissions.check_admin_permissions()
     projects_service.get_project(project_id)
     return entities_service.get_entity_links_for_project(project_id)
示例#13
0
 def delete(self, project_id, task_type_id):
     permissions.check_admin_permissions()
     projects_service.get_project(project_id)
     task_ids = deletion_service.remove_tasks_for_project_and_task_type(
         project_id, task_type_id)
     for task_id in task_ids:
         tasks_service.clear_task_cache(task_id)
     return "", 204
示例#14
0
文件: resources.py 项目: tpolson/zou
 def get(self, person_id, date):
     current_user = persons_service.get_current_user()
     if current_user["id"] != person_id:
         permissions.check_admin_permissions()
     try:
         return time_spents_service.get_day_off(person_id, date)
     except WrongDateFormatException:
         abort(404)
示例#15
0
文件: resources.py 项目: tpolson/zou
 def delete(self, person_id, department_id):
     permissions.check_admin_permissions()
     try:
         department = tasks_service.get_department(department_id)
     except DepartmentNotFoundException:
         raise WrongParameterException("Department ID matches no department")
     persons_service.remove_from_department(department_id, person_id)
     return "", 204
示例#16
0
    def post(self):
        """
        Create a new user in the database. 
        ---
        tags:
        - Persons
        description: Set "default" as password.
                     User role can be set but only admins can create admin users.
        parameters:
          - in: body
            name: User
            description: Email, first and last name, phone, role, desktop login and department of user
            schema:
                type: object
                required:
                - email
                - first_name
                properties:
                    email:
                        type: string
                    first_name:
                        type: string  
                    last_name:
                        type: string
                    phone:
                        type: integer
                        example: 06 12 34 56 78
                    role:
                        type: string
                    desktop_login:
                        type: string
                    departments:
                        type: string
        responses:
            201:
                description: User created
        """
        permissions.check_admin_permissions()
        data = self.get_arguments()

        if persons_service.is_user_limit_reached():
            return {
                "error": True,
                "message": "User limit reached.",
                "limit": config.USER_LIMIT,
            }, 400
        else:
            person = persons_service.create_person(
                data["email"],
                auth.encrypt_password("default"),
                data["first_name"],
                data["last_name"],
                data["phone"],
                role=data["role"],
                desktop_login=data["desktop_login"],
                departments=data["departments"],
            )
        return person, 201
示例#17
0
    def put(self, project_id, descriptor_id):
        args = self.get_args([("name", "", False),
                              ("choices", [], False, "append")])
        permissions.check_admin_permissions()

        if len(args["name"]) == 0:
            raise WrongParameterException("Name cannot be empty.")

        return projects_service.update_metadata_descriptor(descriptor_id, args)
示例#18
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)
示例#19
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
示例#20
0
 def post(self):
     permissions.check_admin_permissions()
     data = self.get_arguments()
     person = persons_service.create_person(
         data["email"],
         auth.encrypt_password("default"),
         data["first_name"],
         data["last_name"],
         data["phone"],
         role=data["role"])
     return person, 201
示例#21
0
 def post(self, person_id):
     permissions.check_admin_permissions()
     args = self.get_args([
         ("department_id", None, True),
     ])
     try:
         department = tasks_service.get_department(args["department_id"])
     except DepartmentNotFoundException:
         raise WrongParameterException("Department ID matches no department")
     person = persons_service.add_to_department(department["id"], person_id)
     return person, 201
示例#22
0
    def get(self):
        name = request.args.get("name", None)
        try:
            permissions.check_admin_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)]
示例#23
0
文件: day_off.py 项目: tpolson/zou
 def update_data(self, data):
     if permissions.check_admin_permissions():
         return data
     else:
         user = persons_service.get_current_user()
         data["person_id"] = user["id"]
     data["date"] = date_helpers.get_date_from_string(data["date"])
     return data
示例#24
0
 def get(self):
     """
     Return the list of projects currently running.
     ---
     tags:
       - Projects
     description: Most of the time, past projects are not needed.
     responses:
         200:
           description: All running projects
     """
     name = request.args.get("name", None)
     try:
         permissions.check_admin_permissions()
         for_client = permissions.has_client_permissions()
         return projects_service.open_projects(name=name,
                                               for_client=for_client)
     except permissions.PermissionDenied:
         return user_service.get_open_projects(name=name)
示例#25
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
示例#26
0
 def get(self, person_id):
     """
     Sends an email to given person to invite him/her to connect to Kitsu.
     ---
     tags:
     - Persons
     parameters:
       - in: path
         name: person_id
         required: True
         schema:
             type: UUID
             example: a24a6ea4-ce75-4665-a070-57453082c25
     responses:
         200:
             description: Email sent
     """
     permissions.check_admin_permissions()
     persons_service.invite_person(person_id)
     return {"success": True, "message": "Email sent"}
示例#27
0
    def post(self):
        permissions.check_admin_permissions()
        data = self.get_arguments()

        if persons_service.is_user_limit_reached():
            return {
                "error": True,
                "message": "User limit reached.",
                "limit": config.USER_LIMIT,
            }, 400
        else:
            person = persons_service.create_person(
                data["email"],
                auth.encrypt_password("default"),
                data["first_name"],
                data["last_name"],
                data["phone"],
                role=data["role"],
                desktop_login=data["desktop_login"],
            )
        return person, 201
示例#28
0
文件: resources.py 项目: cgwire/zou
 def get(self, project_id):
     """
     Retrieve all build jobs related to given project. 
     ---
     tags:
     - Playlists
     description: It's mainly used for synchronisation purpose.
     parameters:
       - in: path
         name: project_id
         required: True
         schema:
             type: UUID
             example: a24a6ea4-ce75-4665-a070-57453082c25
     responses:
         200:
             description: All build jobs related to given project
     """
     permissions.check_admin_permissions()
     projects_service.get_project(project_id)
     return playlists_service.get_build_jobs_for_project(project_id)
示例#29
0
 def get(self, month_date):
     """
     Return a csv file containing the presence logs based on a daily basis.
     ---
     tags:
     - Persons
     parameters:
       - in: path
         name: month_date
         required: True
         schema:
             type: timestamp
             example: 2022-07
     responses:
         200:
             description: CSV file containing the presence logs based on a daily basis
     """
     permissions.check_admin_permissions()
     date = datetime.datetime.strptime(month_date, "%Y-%m")
     presence_logs = persons_service.get_presence_logs(
         date.year, date.month
     )
     return csv_utils.build_csv_response(presence_logs)
示例#30
0
    def get(self):
        """
        Return all projects listed in database. 
        ---
        tags:
          - Projects
        description: Ensure that user has at least the manager level before that.
        responses:
            200:
              description: All projects listed in database
        """
        name = request.args.get("name", None)
        try:
            permissions.check_admin_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)]