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-trusted-release.git


The following commit(s) were added to refs/heads/main by this push:
     new d64f2a1  Add a page listing files in the rsync upload directory
d64f2a1 is described below

commit d64f2a18ad5f2baa87aa0dc0646ecae782a8452d
Author: Sean B. Palmer <[email protected]>
AuthorDate: Fri Mar 21 14:31:48 2025 +0200

    Add a page listing files in the rsync upload directory
---
 atr/routes/files.py           | 35 +++++++++++++++++
 atr/templates/files-add.html  |  2 +-
 atr/templates/files-list.html | 91 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 127 insertions(+), 1 deletion(-)

diff --git a/atr/routes/files.py b/atr/routes/files.py
index 9436bea..4179c1f 100644
--- a/atr/routes/files.py
+++ b/atr/routes/files.py
@@ -29,6 +29,7 @@ import asfquart.session as session
 import quart
 
 import atr.config as config
+import atr.db as db
 import atr.db.models as models
 import atr.routes as routes
 import atr.user as user
@@ -162,3 +163,37 @@ async def root_files_add(session: CommitterSession) -> str:
         number_of_release_files=number_of_release_files,
         editable_releases=user_editable_releases,
     )
+
+
+@committer_get("/files/list/<project_name>/<version_name>")
+async def root_files_list(session: CommitterSession, project_name: str, 
version_name: str) -> str:
+    """Show all the files in the rsync upload directory for a release."""
+    # Check that the user has access to the project
+    if not any((p.name == project_name) for p in (await 
session.user_projects)):
+        raise base.ASFQuartException("You do not have access to this project", 
errorcode=403)
+
+    # Check that the release exists
+    async with db.session() as data:
+        release = await data.release(name=f"{project_name}-{version_name}", 
_project=True).demand(
+            base.ASFQuartException("Release does not exist", errorcode=404)
+        )
+
+    # Get the file list
+    path = os.path.join(_CONFIG.STATE_DIR, "rsync-files", project_name, 
version_name)
+    try:
+        # TODO: Recurse into subdirectories
+        filenames = await aiofiles.os.listdir(path)
+    except FileNotFoundError:
+        filenames = []
+    else:
+        filenames.sort()
+
+    return await quart.render_template(
+        "files-list.html",
+        asf_id=session.uid,
+        project_name=project_name,
+        version_name=version_name,
+        release=release,
+        files=filenames,
+        server_domain=session.host,
+    )
diff --git a/atr/templates/files-add.html b/atr/templates/files-add.html
index 95891d8..44315ee 100644
--- a/atr/templates/files-add.html
+++ b/atr/templates/files-add.html
@@ -40,7 +40,7 @@
             {% endif %}
             <p class="card-text">
               {% if number_of_release_files(release) > 0 %}
-                This editable ongoing release has {{ 
number_of_release_files(release) }} file(s).
+                This editable ongoing release has <a href="{{ 
url_for('root_files_list', project_name=release.project.name, 
version_name=release.version) }}">{{ number_of_release_files(release) }} 
file(s)</a>.
               {% else %}
                 This editable ongoing release doesn't have any files yet.
               {% endif %}
diff --git a/atr/templates/files-list.html b/atr/templates/files-list.html
new file mode 100644
index 0000000..7c4fc41
--- /dev/null
+++ b/atr/templates/files-list.html
@@ -0,0 +1,91 @@
+{% extends "layouts/base.html" %}
+
+{% block title %}
+  Files for {{ project_name }} {{ version_name }} ~ ATR
+{% endblock title %}
+
+{% block description %}
+  View the files for the {{ project_name }} {{ version_name }} release.
+{% endblock description %}
+
+{% block content %}
+  <h1>Files for {{ release.project.display_name }} {{ version_name }}</h1>
+  <p class="intro">This page shows the files for the {{ project_name }} {{ 
version_name }} release.</p>
+
+  <div class="card mb-4">
+    <div class="card-header d-flex justify-content-between align-items-center">
+      <h5 class="mb-0">Release information</h5>
+    </div>
+    <div class="card-body">
+      <div class="row">
+        <div class="col-md-6">
+          <p>
+            <strong>Project:</strong> {{ release.project.display_name }}
+          </p>
+          <p>
+            <strong>Version:</strong> {{ version_name }}
+          </p>
+          <p>
+            <strong>Full name:</strong> {{ release.name }}
+          </p>
+        </div>
+        <div class="col-md-6">
+          <p>
+            <strong>Stage:</strong> <span class="badge bg-{% if release.stage 
== 'CURRENT' %}success{% elif release.stage == 'CANDIDATE' %}warning{% elif 
release.stage == 'BUILD' %}info{% else %}secondary{% endif %}">{{ release.stage 
}}</span>
+          </p>
+          <p>
+            <strong>Phase:</strong> <span class="badge bg-info">{{ 
release.phase }}</span>
+          </p>
+          <p>
+            <strong>Created:</strong> {{ release.created.strftime("%Y-%m-%d 
%H:%M") }}
+          </p>
+        </div>
+      </div>
+    </div>
+  </div>
+
+  <div class="card mb-4">
+    <div class="card-header d-flex justify-content-between align-items-center">
+      <h5 class="mb-0">Files</h5>
+      <a href="{{ url_for('root_files_add') }}"
+         class="btn btn-sm btn-outline-primary">Back to Add files</a>
+    </div>
+    <div class="card-body">
+      {% if files|length > 0 %}
+        <div class="table-responsive">
+          <table class="table table-striped table-hover">
+            <thead>
+              <tr>
+                <th>Filename</th>
+              </tr>
+            </thead>
+            <tbody>
+              {% for file in files %}
+                <tr>
+                  <td>{{ file }}</td>
+                </tr>
+              {% endfor %}
+            </tbody>
+          </table>
+        </div>
+      {% else %}
+        <div class="alert alert-info">
+          This release does not have any files yet. You can add files using 
rsync from the <a href="{{ url_for('root_files_add') }}">add files</a> page.
+        </div>
+      {% endif %}
+    </div>
+  </div>
+
+  <div class="card mb-4">
+    <div class="card-header">
+      <h5 class="mb-0">Add or modify files</h5>
+    </div>
+    <div class="card-body">
+      <p>Use the command below to add or modify files in this release using 
rsync:</p>
+    </div>
+    <pre class="card-footer bg-light border-1 pt-4 small">
+rsync -av -e 'ssh -p 2222' your/files/ \
+    {{ asf_id }}@{{ server_domain }}:/{{ project_name }}/{{ version_name }}/
+    </pre>
+  </div>
+{% endblock content %}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to