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 7e0e405  Split the add and modify candidate drafts page into two 
separate pages
7e0e405 is described below

commit 7e0e40578b821852e47b961fd75edfcc50edf3a9
Author: Sean B. Palmer <[email protected]>
AuthorDate: Thu Mar 27 14:39:45 2025 +0200

    Split the add and modify candidate drafts page into two separate pages
---
 atr/routes/candidate_draft.py                      | 24 +++++--
 atr/templates/candidate-draft-add.html             | 48 +-------------
 ...-draft-add.html => candidate-draft-modify.html} | 77 +---------------------
 atr/templates/includes/sidebar.html                | 39 ++++++-----
 4 files changed, 45 insertions(+), 143 deletions(-)

diff --git a/atr/routes/candidate_draft.py b/atr/routes/candidate_draft.py
index daedb5f..091d86c 100644
--- a/atr/routes/candidate_draft.py
+++ b/atr/routes/candidate_draft.py
@@ -25,7 +25,6 @@ import hashlib
 import logging
 import pathlib
 import re
-import sys
 from typing import Final
 
 import aiofiles.os
@@ -169,7 +168,6 @@ async def add(session: routes.CommitterSession) -> str:
         server_domain=session.host,
         number_of_release_files=_number_of_release_files,
         candidate_drafts=user_candidate_drafts,
-        candidate_draft=sys.modules[__name__],
     )
 
 
@@ -230,7 +228,6 @@ async def add_project(
         project_name=project_name,
         version_name=version_name,
         form=form,
-        candidate_draft=sys.modules[__name__],
     )
 
 
@@ -311,7 +308,6 @@ async def files(session: routes.CommitterSession, 
project_name: str, version_nam
         modified=path_modified,
         tasks=path_tasks,
         models=models,
-        candidate_draft=sys.modules[__name__],
     )
 
 
@@ -363,7 +359,6 @@ async def checks(session: routes.CommitterSession, 
project_name: str, version_na
         tasks=tasks,
         all_tasks_completed=all_tasks_completed,
         format_file_size=routes.format_file_size,
-        candidate_draft=sys.modules[__name__],
     )
 
 
@@ -451,6 +446,24 @@ async def hashgen(
     return quart.redirect(util.as_url(files, project_name=project_name, 
version_name=version_name))
 
 
[email protected]("/candidate-draft/modify")
+async def modify(session: routes.CommitterSession) -> str:
+    """Show a page to allow the user to modify a candidate draft."""
+    # Do them outside of the template rendering call to ensure order
+    # The user_candidate_drafts call can use cached results from user_projects
+    user_projects = await session.user_projects
+    user_candidate_drafts = await session.user_candidate_drafts
+
+    return await quart.render_template(
+        "candidate-draft-modify.html",
+        asf_id=session.uid,
+        projects=user_projects,
+        server_domain=session.host,
+        number_of_release_files=_number_of_release_files,
+        candidate_drafts=user_candidate_drafts,
+    )
+
+
 
@routes.committer("/candidate-draft/tools/<project_name>/<version_name>/<path:file_path>")
 async def tools(session: routes.CommitterSession, project_name: str, 
version_name: str, file_path: str) -> str:
     """Show the tools for a specific file."""
@@ -488,5 +501,4 @@ async def tools(session: routes.CommitterSession, 
project_name: str, version_nam
         file_data=file_data,
         release=release,
         format_file_size=routes.format_file_size,
-        candidate_draft=sys.modules[__name__],
     )
diff --git a/atr/templates/candidate-draft-add.html 
b/atr/templates/candidate-draft-add.html
index 95fafc8..10a94d3 100644
--- a/atr/templates/candidate-draft-add.html
+++ b/atr/templates/candidate-draft-add.html
@@ -1,15 +1,15 @@
 {% extends "layouts/base.html" %}
 
 {% block title %}
-  Candidate drafts ~ ATR
+  Add candidate draft ~ ATR
 {% endblock title %}
 
 {% block description %}
-  Create and modify candidate drafts using rsync.
+  Add a candidate draft using rsync.
 {% endblock description %}
 
 {% block content %}
-  <h1>Candidate drafts</h1>
+  <h1>Add a candidate draft</h1>
   <p class="intro">
     A <strong>candidate draft</strong> is an editable set of files which can 
be <strong>frozen and promoted into a candidate release</strong> for voting on 
by the project's committee.
   </p>
@@ -19,48 +19,6 @@
     <li>A candidate draft is only editable until submitted for voting</li>
   </ul>
 
-  <h2>Modify existing draft</h2>
-  <div class="row row-cols-1 row-cols-md-2 g-4 mb-5">
-    {% for release in candidate_drafts %}
-      <div class="col" id="{{ release.name }}">
-        <div class="card h-100">
-          <div class="card-body position-relative">
-            <div class="position-absolute top-0 end-0 m-2">
-              <span class="badge bg-success">Draft</span>
-            </div>
-            <h5 class="card-title">{{ release.project.display_name }} {{ 
release.version }}</h5>
-            {% if release.project.committee %}
-              <h6 class="card-subtitle mb-2 text-muted">{{ 
release.project.committee.display_name }}</h6>
-            {% endif %}
-            <p class="card-text">
-              {% if number_of_release_files(release) > 0 %}
-                This candidate draft has <a href="{{ 
as_url(routes.candidate_draft.files, project_name=release.project.name, 
version_name=release.version) }}">{{ number_of_release_files(release) }} 
file(s)</a>.
-              {% else %}
-                This candidate draft doesn't have any files yet.
-              {% endif %}
-              <a href="{{ as_url(routes.candidate_draft.add_project, 
project_name=release.project.name, version_name=release.version) }}">Upload a 
file using the browser</a>,
-              or use the command below to add or modify files in this draft:
-            </p>
-          </div>
-          <div class="card-footer bg-light border-1 pt-4 pb-4 
position-relative">
-            <button class="btn btn-sm btn-outline-secondary atr-copy-btn fs-6 
position-absolute top-0 end-0 m-2"
-                    data-clipboard-target="#cmd-{{ release.name|replace('.', 
'-') }}">
-              <i class="bi bi-clipboard"></i> Copy
-            </button>
-            <pre class="small mb-0" id="cmd-{{ release.name|replace('.', '-') 
}}">rsync -av -e 'ssh -p 2222' your/files/ \
-    {{ asf_id }}@{{ server_domain }}:/{{ release.project.name }}/{{ 
release.version }}/</pre>
-          </div>
-        </div>
-      </div>
-    {% endfor %}
-    {% if candidate_drafts|length == 0 %}
-      <div class="col-12">
-        <div class="alert alert-info">There are currently no candidate 
drafts.</div>
-      </div>
-    {% endif %}
-  </div>
-
-  <h2>Create draft from project</h2>
   <div class="row row-cols-1 row-cols-md-2 g-4 mb-5">
     {% for project in projects %}
       {% set candidate_drafts = project.candidate_drafts %}
diff --git a/atr/templates/candidate-draft-add.html 
b/atr/templates/candidate-draft-modify.html
similarity index 56%
copy from atr/templates/candidate-draft-add.html
copy to atr/templates/candidate-draft-modify.html
index 95fafc8..85ef6ab 100644
--- a/atr/templates/candidate-draft-add.html
+++ b/atr/templates/candidate-draft-modify.html
@@ -1,15 +1,15 @@
 {% extends "layouts/base.html" %}
 
 {% block title %}
-  Candidate drafts ~ ATR
+  Modify candidate draft ~ ATR
 {% endblock title %}
 
 {% block description %}
-  Create and modify candidate drafts using rsync.
+  Modify candidate drafts using rsync.
 {% endblock description %}
 
 {% block content %}
-  <h1>Candidate drafts</h1>
+  <h1>Modify a candidate draft</h1>
   <p class="intro">
     A <strong>candidate draft</strong> is an editable set of files which can 
be <strong>frozen and promoted into a candidate release</strong> for voting on 
by the project's committee.
   </p>
@@ -19,7 +19,6 @@
     <li>A candidate draft is only editable until submitted for voting</li>
   </ul>
 
-  <h2>Modify existing draft</h2>
   <div class="row row-cols-1 row-cols-md-2 g-4 mb-5">
     {% for release in candidate_drafts %}
       <div class="col" id="{{ release.name }}">
@@ -59,76 +58,6 @@
       </div>
     {% endif %}
   </div>
-
-  <h2>Create draft from project</h2>
-  <div class="row row-cols-1 row-cols-md-2 g-4 mb-5">
-    {% for project in projects %}
-      {% set candidate_drafts = project.candidate_drafts %}
-
-      {# Show card for creating a new release if allowed #}
-      {% if asf_id in project.committee.committee_members %}
-        <div class="col">
-          <div class="card h-100">
-            <div class="card-body position-relative">
-              <div class="position-absolute top-0 end-0 m-2">
-                <span class="badge bg-primary">Potential</span>
-              </div>
-              <h5 class="card-title">{{ project.display_name }}</h5>
-              {% if project.committee %}
-                <h6 class="card-subtitle mb-2 text-muted">{{ 
project.committee.display_name }}</h6>
-              {% endif %}
-              <p class="card-text">
-                {% if candidate_drafts|length > 0 %}
-                  This project already has candidate drafts
-                  {% for release in candidate_drafts %}
-                    <code><a href="#{{ release.name }}" class="border rounded 
px-2">{{ release.version }}</a></code>,
-                  {% endfor %}
-                  but to create another one, use the command below.
-                {% else %}
-                  This project does not have a candidate draft.
-                  To create one and add files, use the command below.
-                {% endif %}
-              </p>
-            </div>
-            <div class="card-footer bg-light border-1 pt-4 pb-4 
position-relative">
-              <button class="btn btn-sm btn-outline-secondary atr-copy-btn 
fs-6 position-absolute top-0 end-0 m-2"
-                      data-clipboard-target="#cmd-newdraft-{{ 
project.name|replace('.', '-') }}">
-                <i class="bi bi-clipboard"></i> Copy
-              </button>
-              <pre class="small mb-0" id="cmd-newdraft-{{ 
project.name|replace('.', '-') }}">rsync -av -e 'ssh -p 2222' your/files/ \
-    {{ asf_id }}@{{ server_domain }}:/{{ project.name }}/VERSION/</pre>
-            </div>
-          </div>
-        </div>
-      {% else %}
-        <div class="col">
-          <div class="card h-100">
-            <div class="card-body position-relative">
-              <div class="position-absolute top-0 end-0 m-2">
-                <span class="badge bg-secondary">Ask</span>
-              </div>
-              <h5 class="card-title">{{ project.display_name }}</h5>
-              {% if project.committee %}
-                <h6 class="card-subtitle mb-2 text-muted">{{ 
project.committee.display_name }}</h6>
-              {% endif %}
-              <p class="card-text">
-                {% if candidate_drafts|length > 0 %}
-                  This project already has candidate drafts
-                  {% for release in candidate_drafts %}
-                    <code><a href="#{{ release.name }}" class="border rounded 
px-2">{{ release.version }}</a></code>,
-                  {% endfor %}
-                  but to create another one, use the command below.
-                {% else %}
-                  This project does not have a candidate draft.
-                  To create one, you must be a member of the project's 
committee.
-                {% endif %}
-              </p>
-            </div>
-          </div>
-        </div>
-      {% endif %}
-    {% endfor %}
-  </div>
 {% endblock content %}
 
 {% block javascripts %}
diff --git a/atr/templates/includes/sidebar.html 
b/atr/templates/includes/sidebar.html
index b43d8c0..70cf212 100644
--- a/atr/templates/includes/sidebar.html
+++ b/atr/templates/includes/sidebar.html
@@ -27,28 +27,14 @@
     {% endif %}
   </div>
   <nav>
-    <h3>Main pages</h3>
-    <ul>
-      <li>
-        <i class="fa-solid fa-house"></i>
-        <a href="{{ url_for('root') }}"
-           {% if request.endpoint == 'root' %}class="active"{% endif 
%}>About</a>
-      </li>
-      <li>
-        <i class="fa-solid fa-diagram-project"></i>
-        <a href="{{ as_url(routes.committees.directory) }}">Committees</a>
-      </li>
-      <li>
-        <i class="fa-solid fa-diagram-project"></i>
-        <a href="{{ as_url(routes.projects.directory) }}">Projects</a>
-      </li>
-    </ul>
-
     {% if current_user %}
       <h3>Candidate drafts</h3>
       <ul>
         <li>
-          <a href="{{ as_url(routes.candidate_draft.add) }}">Create and 
modify</a>
+          <a href="{{ as_url(routes.candidate_draft.add) }}">Add draft</a>
+        </li>
+        <li>
+          <a href="{{ as_url(routes.candidate_draft.modify) }}">Modify 
draft</a>
         </li>
         <!-- TODO: Don't show this if the user doesn't have any release 
candidates? -->
         <li>
@@ -73,6 +59,23 @@
         </li>
       </ul>
 
+      <h3>Organisation</h3>
+      <ul>
+        <li>
+          <i class="fa-solid fa-house"></i>
+          <a href="{{ url_for('root') }}"
+             {% if request.endpoint == 'root' %}class="active"{% endif 
%}>About</a>
+        </li>
+        <li>
+          <i class="fa-solid fa-diagram-project"></i>
+          <a href="{{ as_url(routes.committees.directory) }}">Committees</a>
+        </li>
+        <li>
+          <i class="fa-solid fa-diagram-project"></i>
+          <a href="{{ as_url(routes.projects.directory) }}">Projects</a>
+        </li>
+      </ul>
+
       {% if is_admin_fn(current_user.uid) %}
         <h3>Administration</h3>
         <ul>


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

Reply via email to