canaille-globuzma/canaille/oidc/authorizations.py

36 lines
1 KiB
Python
Raw Normal View History

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
from flask import abort
from flask import Blueprint
from flask import request
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
@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):
table_form = TableForm(models.AuthorizationCode, formdata=request.form)
if request.form and request.form.get("page") and not table_form.validate():
abort(404)
return render_htmx_template(
2023-08-14 13:28:20 +00:00
"authorization_list.html",
menuitem="admin",
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(
2023-08-14 13:28:20 +00:00
"authorization_view.html",
2022-01-11 18:49:06 +00:00
authorization=authorization,
menuitem="admin",
2020-10-21 10:14:35 +00:00
)