Support for policy upload/download
Plus a small bugfix for groups
This commit is contained in:
@ -8,7 +8,7 @@ from app import auth
|
||||
|
||||
# from ..lib import username
|
||||
|
||||
from flask import jsonify
|
||||
from flask import jsonify, make_response
|
||||
from flask_pyoidc.user_session import UserSession
|
||||
|
||||
from hsapi_client import Node, User, Route, PreAuthKey, Policy
|
||||
@ -132,9 +132,24 @@ def routes():
|
||||
routes=final)
|
||||
|
||||
|
||||
@main_blueprint.route('/policy', methods=['GET'])
|
||||
@main_blueprint.route('/policy', defaults={'action': None}, methods=['GET'])
|
||||
@main_blueprint.route('/policy/<action>', methods=['GET'])
|
||||
@auth.authorize_admins('default')
|
||||
def policy():
|
||||
def policy(action):
|
||||
log.debug(f"action: {action}")
|
||||
policy = Policy().get()
|
||||
return render_template("policy.html",
|
||||
policy=policy)
|
||||
if action == "view":
|
||||
return policy.json
|
||||
|
||||
elif action == "download":
|
||||
updateStr = policy.updatedAt.strftime(format='%Y%m%d-%H%M')
|
||||
log.debug(updateStr)
|
||||
filename = f"acl-{updateStr}.json"
|
||||
response = make_response(policy.json)
|
||||
response.headers['Content-Disposition'] = f'attachment; filename={
|
||||
filename}'
|
||||
|
||||
return response
|
||||
else:
|
||||
return render_template("policy.html",
|
||||
policy=policy)
|
||||
|
Reference in New Issue
Block a user