2023-04-09 09:37:04 +00:00
|
|
|
from canaille.app import models
|
2023-04-09 13:52:55 +00:00
|
|
|
from canaille.app.flask import permissions_needed
|
|
|
|
from canaille.app.flask import render_htmx_template
|
|
|
|
from canaille.app.forms import TableForm
|
2023-02-25 17:11:19 +00:00
|
|
|
from flask import abort
|
2021-10-28 13:24:34 +00:00
|
|
|
from flask import Blueprint
|
2023-02-25 17:11:19 +00:00
|
|
|
from flask import request
|
2021-10-28 13:24:34 +00:00
|
|
|
from flask_themer import render_template
|
2020-08-26 14:27:08 +00:00
|
|
|
|
|
|
|
|
2022-01-11 18:49:06 +00:00
|
|
|
bp = Blueprint("authorizations", __name__, url_prefix="/admin/authorization")
|
2020-08-26 14:27:08 +00:00
|
|
|
|
|
|
|
|
2023-02-25 17:11:19 +00:00
|
|
|
@bp.route("/", methods=["GET", "POST"])
|
2021-12-02 17:23:14 +00:00
|
|
|
@permissions_needed("manage_oidc")
|
2020-10-29 10:09:31 +00:00
|
|
|
def index(user):
|
2023-04-09 09:37:04 +00:00
|
|
|
table_form = TableForm(models.AuthorizationCode, formdata=request.form)
|
2023-02-25 17:11:19 +00:00
|
|
|
if request.form and request.form.get("page") and not table_form.validate():
|
|
|
|
abort(404)
|
|
|
|
|
2023-03-09 16:41:26 +00:00
|
|
|
return render_htmx_template(
|
2022-02-25 12:58:35 +00:00
|
|
|
"oidc/admin/authorization_list.html",
|
|
|
|
menuitem="admin",
|
2023-02-25 17:11:19 +00:00
|
|
|
table_form=table_form,
|
2020-08-27 08:50:50 +00:00
|
|
|
)
|
2020-08-26 14:27:08 +00:00
|
|
|
|
|
|
|
|
2023-06-29 10:15:12 +00:00
|
|
|
@bp.route("/<authorizationcode:authorization>", methods=["GET", "POST"])
|
2021-12-02 17:23:14 +00:00
|
|
|
@permissions_needed("manage_oidc")
|
2023-06-29 10:15:12 +00:00
|
|
|
def view(user, authorization):
|
2020-10-21 10:14:35 +00:00
|
|
|
return render_template(
|
2022-01-11 18:49:06 +00:00
|
|
|
"oidc/admin/authorization_view.html",
|
|
|
|
authorization=authorization,
|
|
|
|
menuitem="admin",
|
2020-10-21 10:14:35 +00:00
|
|
|
)
|