This is an automated email from the ASF dual-hosted git repository. sbp 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 72f6fa9 Add a page to show user uploads 72f6fa9 is described below commit 72f6fa900982eb2ac76c4780a53467afa21f4288 Author: Sean B. Palmer <s...@miscoranda.com> AuthorDate: Thu Feb 13 16:52:45 2025 +0200 Add a page to show user uploads --- atr/routes.py | 31 +++++++++++++-- atr/templates/user-uploads.html | 86 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+), 3 deletions(-) diff --git a/atr/routes.py b/atr/routes.py index eb01b55..aa5cadc 100644 --- a/atr/routes.py +++ b/atr/routes.py @@ -36,6 +36,8 @@ from .models import PMC, Release, ReleaseStage, ReleasePhase, Package if APP is ...: raise ValueError("APP is not set") +ALLOWED_USERS = {"cwells", "fluxo", "gmcdonald", "humbedooh", "sbp", "tn", "wave"} + def compute_sha3_256(file_data: bytes) -> str: "Compute SHA3-256 hash of file data." @@ -173,9 +175,6 @@ async def admin_update_pmcs() -> str: if session is None: raise ASFQuartException("Not authenticated", errorcode=401) - # List of users allowed to update PMCs - ALLOWED_USERS = {"cwells", "fluxo", "gmcdonald", "humbedooh", "sbp", "tn", "wave"} - if session.uid not in ALLOWED_USERS: raise ASFQuartException("You are not authorized to update PMCs", errorcode=403) @@ -322,3 +321,29 @@ async def root() -> str: statement = select(PMC) pmcs = session.exec(statement).all() return await render_template("root.html", pmcs=pmcs) + + +@APP.route("/user/uploads") +@require(R.committer) +async def user_uploads() -> str: + "Show all release candidates uploaded by the current user." + session = await session_read() + if session is None: + raise ASFQuartException("Not authenticated", errorcode=401) + + with Session(current_app.config["engine"]) as db_session: + # Get all releases where the user is a PMC member of the associated PMC + # TODO: We don't actually record who uploaded the release candidate + # We should probably add that information! + statement = select(Release).join(PMC).where(Release.stage == ReleaseStage.CANDIDATE) + releases = db_session.exec(statement).all() + + # Filter to only show releases for PMCs where the user is a member + user_releases = [] + for r in releases: + if r.pmc is None: + continue + if session.uid in r.pmc.pmc_members: + user_releases.append(r) + + return await render_template("user-uploads.html", releases=user_releases) diff --git a/atr/templates/user-uploads.html b/atr/templates/user-uploads.html new file mode 100644 index 0000000..3a61d39 --- /dev/null +++ b/atr/templates/user-uploads.html @@ -0,0 +1,86 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width,initial-scale=1.0" /> + <meta name="description" content="Your uploaded release candidates." /> + <title>ATR | Your Uploads</title> + <link rel="stylesheet" href="{{ url_for('static', filename='root.css') }}" /> + <style> + .release-list { + margin: 1rem 0; + } + + .release { + border: 1px solid #ddd; + padding: 1rem; + margin-bottom: 1rem; + border-radius: 4px; + } + + .release-header { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 0.5rem; + } + + .release-meta { + color: #666; + font-size: 0.9em; + } + + .package-list { + margin-top: 0.5rem; + } + + .package { + background: #f5f5f5; + padding: 0.5rem; + margin: 0.25rem 0; + border-radius: 2px; + } + + .no-releases { + color: #666; + font-style: italic; + } + </style> + </head> + <body> + <h1>Your Uploads</h1> + <p class="intro">Here are all the release candidates you've uploaded.</p> + + {% if releases %} + <div class="release-list"> + {% for release in releases %} + <div class="release"> + <div class="release-header"> + <h3>{{ release.pmc.project_name }}</h3> + <span class="release-meta"> + Stage: {{ release.stage.value }} + • + Phase: {{ release.phase.value }} + </span> + </div> + <div class="package-list"> + {% for package in release.packages %} + <div class="package"> + <div>File: {{ package.file }}</div> + <div>Signature: {{ package.signature }}</div> + <div>Checksum (SHA-512): {{ package.checksum }}</div> + </div> + {% endfor %} + </div> + </div> + {% endfor %} + </div> + {% else %} + <p class="no-releases">You haven't uploaded any release candidates yet.</p> + {% endif %} + + <p> + <a href="{{ url_for('add_release_candidate') }}">Upload a new release candidate</a> + </p> + </body> +</html> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tooling.apache.org For additional commands, e-mail: dev-h...@tooling.apache.org