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)

[((287, 343), 'app.blueprints.base_blueprint.Blueprint', 'Blueprint', (['"""department"""', '__name__'], {'url_prefix': 'url_prefix'}), "('department', __name__, url_prefix=url_prefix)\n", (296, 343), False, 'from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request, Security, Auth\n'), ((368, 397), 'app.controllers.department_controller.DepartmentController', 'DepartmentController', (['request'], {}), '(request)\n', (388, 397), False, 'from app.controllers.department_controller import DepartmentController\n'), ((451, 489), 'app.blueprints.base_blueprint.Auth.has_permission', 'Auth.has_permission', (['"""view_department"""'], {}), "('view_department')\n", (470, 489), False, 'from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request, Security, Auth\n'), ((491, 541), 'flasgger.swag_from', 'swag_from', (['"""documentation/get_all_departments.yml"""'], {}), "('documentation/get_all_departments.yml')\n", (500, 541), False, 'from flasgger import swag_from\n'), ((686, 724), 'app.blueprints.base_blueprint.Auth.has_permission', 'Auth.has_permission', (['"""view_department"""'], {}), "('view_department')\n", (705, 724), False, 'from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request, Security, Auth\n'), ((726, 778), 'flasgger.swag_from', 'swag_from', (['"""documentation/get_single_department.yml"""'], {}), "('documentation/get_single_department.yml')\n", (735, 778), False, 'from flasgger import swag_from\n'), ((927, 949), 'app.blueprints.base_blueprint.Auth.has_role', 'Auth.has_role', (['"""admin"""'], {}), "('admin')\n", (940, 949), False, 'from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request, Security, Auth\n'), ((951, 1041), 'app.blueprints.base_blueprint.Security.validator', 'Security.validator', (["['name|required:ifExists_Department_name', 'description|required']"], {}), "(['name|required:ifExists_Department_name',\n    'description|required'])\n", (969, 1041), False, 'from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request, Security, Auth\n'), ((1039, 1087), 'flasgger.swag_from', 'swag_from', (['"""documentation/create_department.yml"""'], {}), "('documentation/create_department.yml')\n", (1048, 1087), False, 'from flasgger import swag_from\n'), ((1237, 1259), 'app.blueprints.base_blueprint.Auth.has_role', 'Auth.has_role', (['"""admin"""'], {}), "('admin')\n", (1250, 1259), False, 'from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request, Security, Auth\n'), ((1261, 1309), 'flasgger.swag_from', 'swag_from', (['"""documentation/delete_department.yml"""'], {}), "('documentation/delete_department.yml')\n", (1270, 1309), False, 'from flasgger import swag_from\n'), ((1484, 1506), 'app.blueprints.base_blueprint.Auth.has_role', 'Auth.has_role', (['"""admin"""'], {}), "('admin')\n", (1497, 1506), False, 'from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request, Security, Auth\n'), ((1508, 1569), 'app.blueprints.base_blueprint.Security.validator', 'Security.validator', (["['name|optional', 'description|optional']"], {}), "(['name|optional', 'description|optional'])\n", (1526, 1569), False, 'from app.blueprints.base_blueprint import Blueprint, BaseBlueprint, request, Security, Auth\n'), ((1571, 1619), 'flasgger.swag_from', 'swag_from', (['"""documentation/update_department.yml"""'], {}), "('documentation/update_department.yml')\n", (1580, 1619), False, 'from flasgger import swag_from\n')]