This is an automated email from the ASF dual-hosted git repository.
tn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-atr-experiments.git
The following commit(s) were added to refs/heads/main by this push:
new 84a34ef chore: refactor secret blueprint to admin, add base-admin
layout, minor css changes
84a34ef is described below
commit 84a34efee062f02404a8deeb92e2ae67fb98a3e3
Author: Thomas Neidhart <[email protected]>
AuthorDate: Mon Mar 3 15:52:56 2025 +0100
chore: refactor secret blueprint to admin, add base-admin layout, minor css
changes
---
atr/blueprints/__init__.py | 2 +-
atr/blueprints/{secret => admin}/__init__.py | 4 +++-
.../{secret/secret.py => admin/admin.py} | 25 ++++++++++------------
.../admin/templates}/data-browser.html | 4 ++--
.../admin/templates}/performance.html | 2 +-
.../admin/templates}/update-pmcs.html | 2 +-
atr/static/css/atr.css | 20 ++++++++++++-----
atr/templates/includes/sidebar.html | 12 +++++------
atr/templates/layouts/base-admin.html | 5 +++++
atr/templates/layouts/base.html | 2 +-
10 files changed, 46 insertions(+), 32 deletions(-)
diff --git a/atr/blueprints/__init__.py b/atr/blueprints/__init__.py
index 4d8d1cf..3bf3c36 100644
--- a/atr/blueprints/__init__.py
+++ b/atr/blueprints/__init__.py
@@ -20,7 +20,7 @@ from importlib.util import find_spec
from asfquart.base import QuartApp
-_BLUEPRINT_MODULES = ["api", "secret"]
+_BLUEPRINT_MODULES = ["api", "admin"]
def register_blueprints(app: QuartApp) -> None:
diff --git a/atr/blueprints/secret/__init__.py
b/atr/blueprints/admin/__init__.py
similarity index 90%
rename from atr/blueprints/secret/__init__.py
rename to atr/blueprints/admin/__init__.py
index c82efc1..dca4086 100644
--- a/atr/blueprints/secret/__init__.py
+++ b/atr/blueprints/admin/__init__.py
@@ -15,6 +15,8 @@
# specific language governing permissions and limitations
# under the License.
+"""Any routes related to the admin interface of the ATR."""
+
from quart import Blueprint
from asfquart.auth import Requirements, require
@@ -22,7 +24,7 @@ from asfquart.base import ASFQuartException
from asfquart.session import read as session_read
from atr.util import get_admin_users
-blueprint = Blueprint("secret_blueprint", __name__, url_prefix="/secret")
+blueprint = Blueprint("admin", __name__, url_prefix="/admin",
template_folder="templates")
@blueprint.before_request
diff --git a/atr/blueprints/secret/secret.py b/atr/blueprints/admin/admin.py
similarity index 93%
rename from atr/blueprints/secret/secret.py
rename to atr/blueprints/admin/admin.py
index aba14b3..6240234 100644
--- a/atr/blueprints/secret/secret.py
+++ b/atr/blueprints/admin/admin.py
@@ -15,7 +15,6 @@
# specific language governing permissions and limitations
# under the License.
-
from collections import defaultdict
from pathlib import Path
from statistics import mean, median, stdev
@@ -51,7 +50,7 @@ from . import blueprint
@blueprint.route("/performance")
-async def secret_performance() -> str:
+async def admin_performance() -> str:
"""Display performance statistics for all routes."""
from asfquart import APP
@@ -68,7 +67,7 @@ async def secret_performance() -> str:
# await asyncio.to_thread(APP.logger.info, "Files in current directory:
%s", files)
if not await aiofiles.os.path.exists(log_path):
await flash("No performance data currently available", "error")
- return await render_template("secret/performance.html", stats=None)
+ return await render_template("performance.html", stats=None)
# Parse the log file and collect statistics
stats = defaultdict(list)
@@ -128,12 +127,12 @@ async def secret_performance() -> str:
return x[1]["total"]["mean"]
sorted_summary = dict(sorted(summary.items(), key=one_total_mean,
reverse=True))
- return await render_template("secret/performance.html",
stats=sorted_summary)
+ return await render_template("performance.html", stats=sorted_summary)
@blueprint.route("/data")
@blueprint.route("/data/<model>")
-async def secret_data(model: str = "PMC") -> str:
+async def admin_data(model: str = "PMC") -> str:
"""Browse all records in the database."""
# Map of model names to their classes
@@ -173,13 +172,11 @@ async def secret_data(model: str = "PMC") -> str:
record_dict[key] = getattr(record, key)
records_dict.append(record_dict)
- return await render_template(
- "secret/data-browser.html", models=list(models.keys()),
model=model, records=records_dict
- )
+ return await render_template("data-browser.html",
models=list(models.keys()), model=model, records=records_dict)
@blueprint.route("/projects/update", methods=["GET", "POST"])
-async def secret_projects_update() -> str | Response:
+async def admin_projects_update() -> str | Response:
"""Update projects from remote data."""
if request.method == "POST":
try:
@@ -188,7 +185,7 @@ async def secret_projects_update() -> str | Response:
groups_data = await get_groups_data()
except httpx.RequestError as e:
await flash(f"Failed to fetch data: {e!s}", "error")
- return redirect(url_for("secret_blueprint.secret_projects_update"))
+ return redirect(url_for("admin.admin_projects_update"))
updated_count = 0
@@ -265,21 +262,21 @@ async def secret_projects_update() -> str | Response:
except Exception as e:
await flash(f"Failed to update projects: {e!s}", "error")
- return redirect(url_for("secret_blueprint.secret_projects_update"))
+ return redirect(url_for("admin.admin_projects_update"))
# For GET requests, show the update form
- return await render_template("secret/update-pmcs.html")
+ return await render_template("update-pmcs.html")
@blueprint.route("/debug/database")
-async def secret_debug_database() -> str:
+async def admin_debug_database() -> str:
"""Debug information about the database."""
pmcs = await get_pmcs()
return f"Database using {current_app.config['DATA_MODELS_FILE']} has
{len(pmcs)} PMCs"
@blueprint.route("/keys/delete-all")
-async def secret_keys_delete_all() -> str:
+async def admin_keys_delete_all() -> str:
"""Debug endpoint to delete all of a user's keys."""
session = await session_read()
if session is None:
diff --git a/atr/templates/secret/data-browser.html
b/atr/blueprints/admin/templates/data-browser.html
similarity index 94%
rename from atr/templates/secret/data-browser.html
rename to atr/blueprints/admin/templates/data-browser.html
index 61866bc..0932431 100644
--- a/atr/templates/secret/data-browser.html
+++ b/atr/blueprints/admin/templates/data-browser.html
@@ -1,4 +1,4 @@
-{% extends "layouts/base.html" %}
+{% extends "layouts/base-admin.html" %}
{% block title %}
Data browser ~ ATR
@@ -70,7 +70,7 @@
<div class="model-nav">
{% for model_name in models %}
- <a href="{{ url_for('secret_blueprint.secret_data', model=model_name) }}"
+ <a href="{{ url_for('admin.admin_data', model=model_name) }}"
{% if model == model_name %}class="active"{% endif %}>{{ model_name
}}</a>
{% endfor %}
</div>
diff --git a/atr/templates/secret/performance.html
b/atr/blueprints/admin/templates/performance.html
similarity index 99%
rename from atr/templates/secret/performance.html
rename to atr/blueprints/admin/templates/performance.html
index ed89403..f07848d 100644
--- a/atr/templates/secret/performance.html
+++ b/atr/blueprints/admin/templates/performance.html
@@ -1,4 +1,4 @@
-{% extends "layouts/base.html" %}
+{% extends "layouts/base-admin.html" %}
{% block title %}
Performance dashboard
diff --git a/atr/templates/secret/update-pmcs.html
b/atr/blueprints/admin/templates/update-pmcs.html
similarity index 97%
rename from atr/templates/secret/update-pmcs.html
rename to atr/blueprints/admin/templates/update-pmcs.html
index 149bef4..bbb272d 100644
--- a/atr/templates/secret/update-pmcs.html
+++ b/atr/blueprints/admin/templates/update-pmcs.html
@@ -1,4 +1,4 @@
-{% extends "layouts/base.html" %}
+{% extends "layouts/base-admin.html" %}
{% block title %}
Update projects ~ ATR
diff --git a/atr/static/css/atr.css b/atr/static/css/atr.css
index 6a12c42..718b99a 100644
--- a/atr/static/css/atr.css
+++ b/atr/static/css/atr.css
@@ -125,7 +125,7 @@ pre {
}
footer {
- padding: 2rem;
+ padding: 1rem;
background: #eeeeee;
font-size: 15px;
margin: 2rem;
@@ -133,16 +133,22 @@ footer {
font-variation-settings: "opsz" 14;
border-radius: 0.5rem;
border: 2px solid #d1d2d3;
+ display: table;
+ text-align: center;
}
footer a {
- color: #333333;
- font-weight: 425;
+ color: #333333;
+ font-weight: 425;
}
footer a:visited {
- color: #333333;
- font-weight: 425;
+ color: #333333;
+ font-weight: 425;
+}
+
+footer p {
+ margin-bottom: 0;
}
button {
@@ -367,3 +373,7 @@ span.warning {
border: 1px solid #c3e6cb;
color: #155724;
}
+
+.admin-content {
+ box-shadow:inset 0 0 0 10px #dc3545;
+}
diff --git a/atr/templates/includes/sidebar.html
b/atr/templates/includes/sidebar.html
index 4e4c814..0a89aaa 100644
--- a/atr/templates/includes/sidebar.html
+++ b/atr/templates/includes/sidebar.html
@@ -74,16 +74,16 @@
<h3>Administration</h3>
<ul>
<li>
- <a href="{{ url_for('secret_blueprint.secret_data') }}"
- {% if request.endpoint == 'secret_blueprint.secret_data'
%}class="active"{% endif %}>Browse database</a>
+ <a href="{{ url_for('admin.admin_data') }}"
+ {% if request.endpoint == 'admin.admin_data' %}class="active"{%
endif %}>Browse database</a>
</li>
<li>
- <a href="{{ url_for('secret_blueprint.secret_projects_update') }}"
- {% if request.endpoint ==
'secret_blueprint.secret_projects_update' %}class="active"{% endif %}>Update
projects</a>
+ <a href="{{ url_for('admin.admin_projects_update') }}"
+ {% if request.endpoint == 'admin.admin_projects_update'
%}class="active"{% endif %}>Update projects</a>
</li>
<li>
- <a href="{{ url_for('secret_blueprint.secret_performance') }}"
- {% if request.endpoint == 'secret_blueprint.secret_performance'
%}class="active"{% endif %}>Performance dashboard</a>
+ <a href="{{ url_for('admin.admin_performance') }}"
+ {% if request.endpoint == 'admin.admin_performance'
%}class="active"{% endif %}>Performance dashboard</a>
</li>
</ul>
{% endif %}
diff --git a/atr/templates/layouts/base-admin.html
b/atr/templates/layouts/base-admin.html
new file mode 100644
index 0000000..ab1f7e1
--- /dev/null
+++ b/atr/templates/layouts/base-admin.html
@@ -0,0 +1,5 @@
+{% extends "layouts/base.html" %}
+
+{% block main_class %}
+ admin-content
+{% endblock main_class %}
diff --git a/atr/templates/layouts/base.html b/atr/templates/layouts/base.html
index 9b3f89d..1cdcea4 100644
--- a/atr/templates/layouts/base.html
+++ b/atr/templates/layouts/base.html
@@ -42,7 +42,7 @@
{% include "includes/sidebar.html" %}
- <div class="main-container">
+ <div class="main-container {% block main_class %}{% endblock
main_class %}">
<main class="main-content">
<div class="warning-banner">
<strong>Pre-release Software:</strong> ATR is actively being
developed. You cannot make releases.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]