Move ccpo routes into their own file
This commit is contained in:
@@ -18,6 +18,7 @@ from atst.routes.applications import applications_bp
|
||||
from atst.routes.dev import bp as dev_routes
|
||||
from atst.routes.users import bp as user_routes
|
||||
from atst.routes.errors import make_error_pages
|
||||
from atst.routes.ccpo import bp as ccpo_routes
|
||||
from atst.domain.authnid.crl import CRLCache, NoOpCRLCache
|
||||
from atst.domain.auth import apply_authentication
|
||||
from atst.domain.authz import Authorization
|
||||
@@ -78,6 +79,7 @@ def make_app(config):
|
||||
app.register_blueprint(task_orders_bp)
|
||||
app.register_blueprint(applications_bp)
|
||||
app.register_blueprint(user_routes)
|
||||
app.register_blueprint(ccpo_routes)
|
||||
|
||||
if ENV != "prod":
|
||||
app.register_blueprint(dev_routes)
|
||||
|
@@ -128,50 +128,6 @@ def logout():
|
||||
return response
|
||||
|
||||
|
||||
@bp.route("/activity-history")
|
||||
@user_can(Permissions.VIEW_AUDIT_LOG, message="view activity log")
|
||||
def activity_history():
|
||||
pagination_opts = Paginator.get_pagination_opts(request)
|
||||
audit_events = AuditLog.get_all_events(pagination_opts)
|
||||
return render_template("audit_log/audit_log.html", audit_events=audit_events)
|
||||
|
||||
|
||||
@bp.route("/ccpo-users")
|
||||
@user_can(Permissions.VIEW_CCPO_USER, message="view ccpo users")
|
||||
def ccpo_users():
|
||||
users = Users.get_ccpo_users()
|
||||
return render_template("ccpo/users.html", users=users)
|
||||
|
||||
|
||||
@bp.route("/ccpo-users/new")
|
||||
@user_can(Permissions.CREATE_CCPO_USER, message="create ccpo user")
|
||||
def add_new_ccpo_user():
|
||||
form = CCPOUserForm()
|
||||
return render_template("ccpo/add_user.html", form=form)
|
||||
|
||||
|
||||
@bp.route("/ccpo-users/new", methods=["POST"])
|
||||
@user_can(Permissions.CREATE_CCPO_USER, message="create ccpo user")
|
||||
def submit_add_new_ccpo_user():
|
||||
try:
|
||||
new_user = Users.get_by_dod_id(request.form["dod_id"])
|
||||
form = CCPOUserForm(obj=new_user)
|
||||
except NotFoundError:
|
||||
new_user = None
|
||||
form = CCPOUserForm()
|
||||
|
||||
return render_template("ccpo/confirm_user.html", new_user=new_user, form=form)
|
||||
|
||||
|
||||
@bp.route("/ccpo-users/confirm-new", methods=["POST"])
|
||||
@user_can(Permissions.CREATE_CCPO_USER, message="create ccpo user")
|
||||
def confirm_new_ccpo_user():
|
||||
user = Users.get_by_dod_id(request.form["dod_id"])
|
||||
Users.update_ccpo_permissions(user, add_perms=True)
|
||||
flash("ccpo_user_added", user_name=user.full_name)
|
||||
return redirect(url_for("atst.ccpo_users"))
|
||||
|
||||
|
||||
@bp.route("/about")
|
||||
def about():
|
||||
return render_template("about.html")
|
||||
|
58
atst/routes/ccpo.py
Normal file
58
atst/routes/ccpo.py
Normal file
@@ -0,0 +1,58 @@
|
||||
from flask import Blueprint, render_template, redirect, url_for, request
|
||||
from atst.domain.users import Users
|
||||
from atst.domain.audit_log import AuditLog
|
||||
from atst.domain.common import Paginator
|
||||
from atst.domain.exceptions import NotFoundError
|
||||
from atst.domain.authz.decorator import user_can_access_decorator as user_can
|
||||
from atst.forms.ccpo_user import CCPOUserForm
|
||||
from atst.models.permissions import Permissions
|
||||
from atst.utils.context_processors import atat as atat_context_processor
|
||||
from atst.utils.flash import formatted_flash as flash
|
||||
|
||||
|
||||
bp = Blueprint("ccpo", __name__)
|
||||
bp.context_processor(atat_context_processor)
|
||||
|
||||
|
||||
@bp.route("/activity-history")
|
||||
@user_can(Permissions.VIEW_AUDIT_LOG, message="view activity log")
|
||||
def activity_history():
|
||||
pagination_opts = Paginator.get_pagination_opts(request)
|
||||
audit_events = AuditLog.get_all_events(pagination_opts)
|
||||
return render_template("audit_log/audit_log.html", audit_events=audit_events)
|
||||
|
||||
|
||||
@bp.route("/ccpo-users")
|
||||
@user_can(Permissions.VIEW_CCPO_USER, message="view ccpo users")
|
||||
def ccpo_users():
|
||||
users = Users.get_ccpo_users()
|
||||
return render_template("ccpo/users.html", users=users)
|
||||
|
||||
|
||||
@bp.route("/ccpo-users/new")
|
||||
@user_can(Permissions.CREATE_CCPO_USER, message="create ccpo user")
|
||||
def add_new_ccpo_user():
|
||||
form = CCPOUserForm()
|
||||
return render_template("ccpo/add_user.html", form=form)
|
||||
|
||||
|
||||
@bp.route("/ccpo-users/new", methods=["POST"])
|
||||
@user_can(Permissions.CREATE_CCPO_USER, message="create ccpo user")
|
||||
def submit_add_new_ccpo_user():
|
||||
try:
|
||||
new_user = Users.get_by_dod_id(request.form["dod_id"])
|
||||
form = CCPOUserForm(obj=new_user)
|
||||
except NotFoundError:
|
||||
new_user = None
|
||||
form = CCPOUserForm()
|
||||
|
||||
return render_template("ccpo/confirm_user.html", new_user=new_user, form=form)
|
||||
|
||||
|
||||
@bp.route("/ccpo-users/confirm-new", methods=["POST"])
|
||||
@user_can(Permissions.CREATE_CCPO_USER, message="create ccpo user")
|
||||
def confirm_new_ccpo_user():
|
||||
user = Users.get_by_dod_id(request.form["dod_id"])
|
||||
Users.update_ccpo_permissions(user, add_perms=True)
|
||||
flash("ccpo_user_added", user_name=user.full_name)
|
||||
return redirect(url_for("ccpo.ccpo_users"))
|
Reference in New Issue
Block a user