from flasgger import swag_from

from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request, Security, Auth
from app.controllers.department_controller import DepartmentController

url_prefix = '{}/departments'.format(BaseBlueprint.base_url_prefix)
department_blueprint = Blueprint('department', __name__, url_prefix=url_prefix)
department_controller = DepartmentController(request)
	
@department_blueprint.route('/', methods=['GET'])
@Auth.has_permission('view_department')
@swag_from('documentation/get_all_departments.yml')
def list_departments():
	return department_controller.list_departments()

@department_blueprint.route('/<int:department_id>', methods=['GET'])
@Auth.has_permission('view_department')
@swag_from('documentation/get_single_department.yml')
def get_department(department_id):
	return department_controller.get_department(department_id)

@department_blueprint.route('/', methods=['POST'])
@Auth.has_role('admin')
@Security.validator(['name|required:ifExists_Department_name', 'description|required'])
@swag_from('documentation/create_department.yml')
def create_department():
	return department_controller.create_department()

@department_blueprint.route('/<int:department_id>', methods=['DELETE'])
@Auth.has_role('admin')
@swag_from('documentation/delete_department.yml')
def delete_department(department_id):
	return department_controller.delete_department(department_id)

@department_blueprint.route('/<int:department_id>', methods=['PATCH'])
@Auth.has_role('admin')
@Security.validator(['name|optional', 'description|optional'])
@swag_from('documentation/update_department.yml')
def update_department(department_id):
	return department_controller.update_department(department_id)

[((7, 23, 7, 79), 'app.blueprints.base_blueprint.Blueprint', 'Blueprint', (), '', False, 'from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request, Security, Auth\n'), ((8, 24, 8, 53), 'app.controllers.department_controller.DepartmentController', 'DepartmentController', ({(8, 45, 8, 52): 'request'}, {}), '(request)', False, 'from app.controllers.department_controller import DepartmentController\n'), ((11, 1, 11, 39), 'app.blueprints.base_blueprint.Auth.has_permission', 'Auth.has_permission', ({(11, 21, 11, 38): '"""view_department"""'}, {}), "('view_department')", False, 'from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request, Security, Auth\n'), ((12, 1, 12, 51), 'flasgger.swag_from', 'swag_from', ({(12, 11, 12, 50): '"""documentation/get_all_departments.yml"""'}, {}), "('documentation/get_all_departments.yml')", False, 'from flasgger import swag_from\n'), ((17, 1, 17, 39), 'app.blueprints.base_blueprint.Auth.has_permission', 'Auth.has_permission', ({(17, 21, 17, 38): '"""view_department"""'}, {}), "('view_department')", False, 'from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request, Security, Auth\n'), ((18, 1, 18, 53), 'flasgger.swag_from', 'swag_from', ({(18, 11, 18, 52): '"""documentation/get_single_department.yml"""'}, {}), "('documentation/get_single_department.yml')", False, 'from flasgger import swag_from\n'), ((23, 1, 23, 23), 'app.blueprints.base_blueprint.Auth.has_role', 'Auth.has_role', ({(23, 15, 23, 22): '"""admin"""'}, {}), "('admin')", False, 'from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request, Security, Auth\n'), ((24, 1, 24, 87), 'app.blueprints.base_blueprint.Security.validator', 'Security.validator', ({(24, 20, 24, 86): "['name|required:ifExists_Department_name', 'description|required']"}, {}), "(['name|required:ifExists_Department_name',\n    'description|required'])", False, 'from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request, Security, Auth\n'), ((25, 1, 25, 49), 'flasgger.swag_from', 'swag_from', ({(25, 11, 25, 48): '"""documentation/create_department.yml"""'}, {}), "('documentation/create_department.yml')", False, 'from flasgger import swag_from\n'), ((30, 1, 30, 23), 'app.blueprints.base_blueprint.Auth.has_role', 'Auth.has_role', ({(30, 15, 30, 22): '"""admin"""'}, {}), "('admin')", False, 'from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request, Security, Auth\n'), ((31, 1, 31, 49), 'flasgger.swag_from', 'swag_from', ({(31, 11, 31, 48): '"""documentation/delete_department.yml"""'}, {}), "('documentation/delete_department.yml')", False, 'from flasgger import swag_from\n'), ((36, 1, 36, 23), 'app.blueprints.base_blueprint.Auth.has_role', 'Auth.has_role', ({(36, 15, 36, 22): '"""admin"""'}, {}), "('admin')", False, 'from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request, Security, Auth\n'), ((37, 1, 37, 62), 'app.blueprints.base_blueprint.Security.validator', 'Security.validator', ({(37, 20, 37, 61): "['name|optional', 'description|optional']"}, {}), "(['name|optional', 'description|optional'])", False, 'from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request, Security, Auth\n'), ((38, 1, 38, 49), 'flasgger.swag_from', 'swag_from', ({(38, 11, 38, 48): '"""documentation/update_department.yml"""'}, {}), "('documentation/update_department.yml')", False, 'from flasgger import swag_from\n')]