From 2d3d03e01ec74d4a957087b0447acbb67adb5e3d Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Wed, 14 Jul 2021 14:08:14 -0700 Subject: [PATCH] templates: Translate pkgbase.html and partials + Include the `is_maintainer` context key. + Use `is_maintainer` in more locations. Signed-off-by: Kevin Morris --- aurweb/routers/packages.py | 2 + templates/partials/packages/comments.html | 48 +++++++---- .../partials/packages/package_actions.html | 82 +++++++++++++++---- templates/partials/packages/search.html | 62 +++++++------- templates/pkgbase.html | 36 ++++---- 5 files changed, 155 insertions(+), 75 deletions(-) diff --git a/aurweb/routers/packages.py b/aurweb/routers/packages.py index 80a4221b..0bd19041 100644 --- a/aurweb/routers/packages.py +++ b/aurweb/routers/packages.py @@ -28,6 +28,8 @@ async def package_base(request: Request, package: str): context["packages_count"] = package.packages.count() context["keywords"] = package.keywords.all() context["comments"] = package.comments.all() + context["is_maintainer"] = request.user.is_authenticated() \ + and request.user.Username == package.Maintainer.Username return render_template(request, "pkgbase.html", context) diff --git a/templates/partials/packages/comments.html b/templates/partials/packages/comments.html index 48bc88e6..39b0d2b4 100644 --- a/templates/partials/packages/comments.html +++ b/templates/partials/packages/comments.html @@ -14,18 +14,23 @@

- Git commit identifiers referencing commits in the AUR package - repository and URLs are converted to links automatically. - - Markdown syntax - - is partially supported. + {{ + "Git commit identifiers referencing commits in the AUR package" + " repository and URLs are converted to links automatically." + | tr + }} + {{ + "%sMarkdown Syntax%s is partially supported." + | tr + | format('', '') + | safe + }}

- +

@@ -34,22 +39,35 @@

- Latest Comments + {{ "Latest Comments" | tr }}

{% for comment in comments %}

- {% set commentTimestamp = comment.CommentTS | dt | as_timezone(timezone) %} - {{ comment.User.Username }} - commented on {{ "%s" | tr | format(commentTimestamp.strftime("%Y-%m-%d %H:%M")) }} - {% if request.user.is_authenticated() and pkgbase.Maintainer.Username == request.user.Username %} + {% set commented_at = comment.CommentTS | dt | as_timezone(timezone) %} + {% set view_account_info = 'View account information for %s' | tr | format(comment.User.Username) %} + {{ + "%s commented on %s" | tr | format( + '%s' | format( + comment.User.Username, + view_account_info, + comment.User.Username + ), + '%s' | format( + comment.ID, + commented_at.strftime("%Y-%m-%d %H:%M") + ) + ) + | safe + }} + {% if is_maintainer %}
- +
Edit comment @@ -60,13 +78,13 @@ - +

-

{{ comment.Comments }}

+

{{ comment.RenderedComment | safe }}

{% endfor %} diff --git a/templates/partials/packages/package_actions.html b/templates/partials/packages/package_actions.html index 36844214..4e7da882 100644 --- a/templates/partials/packages/package_actions.html +++ b/templates/partials/packages/package_actions.html @@ -3,31 +3,85 @@ --> diff --git a/templates/partials/packages/search.html b/templates/partials/packages/search.html index b6b2da1b..c4488b95 100644 --- a/templates/partials/packages/search.html +++ b/templates/partials/packages/search.html @@ -4,55 +4,55 @@

- Enter search criteria + {{ "Enter search criteria" | tr }}
- +
- +
- +
- +
- +
- + - + +
diff --git a/templates/pkgbase.html b/templates/pkgbase.html index 939aef10..d608fa2e 100644 --- a/templates/pkgbase.html +++ b/templates/pkgbase.html @@ -3,7 +3,7 @@ {% block pageContent %} {% include "partials/packages/search.html" %}
-

Package Base Details: {{ pkgbase.Name }}

+

Package Details: {{ pkgbase.Name }}

{% set result = pkgbase %} {% set pkgname = "result.Name" %} @@ -11,17 +11,17 @@ - + - - {% if request.user.is_authenticated() and pkgbase.Maintainer.Username == request.user.Username %} + + {% if is_maintainer %} - + - + - + - + - + {% set submitted = pkgbase.SubmittedTS | dt | as_timezone(timezone) %} - + - + {% set updated = pkgbase.ModifiedTS | dt | as_timezone(timezone) %} @@ -73,10 +73,16 @@
+

Packages ({{ packages_count }})

Git Clone URL: {{ "Git Clone URL" | tr }}: - {{ git_clone_uri_anon | format(pkgbase.Name) }} (read-only, click to copy) - {% if request.user.is_authenticated() and pkgbase.Maintainer.Username == request.user.Username %} -
{{ git_clone_uri_priv | format(pkgbase.Name) }} (click to copy) + {{ git_clone_uri_anon | format(pkgbase.Name) }} ({{ "read-only" | tr }}, {{ "click to copy" | tr }}) + {% if is_maintainer %} +
{{ git_clone_uri_priv | format(pkgbase.Name) }} ({{ "click to copy" | tr }}) {% endif %}
Keywords: {{ "Keywords" | tr }}:
@@ -40,32 +40,32 @@ {% endif %}
Submitter: {{ "Submitter" | tr }}: {{ pkgbase.Submitter.Username | default("None") }}
Maintainer: {{ "Maintainer" | tr }}: {{ pkgbase.Maintainer.Username | default("None") }}
Last Packager: {{ "Last Packager" | tr }}: {{ pkgbase.Packager.Username | default("None") }}
Votes: {{ "Votes" | tr }}: {{ pkgbase.NumVotes }}
Popularity: {{ "Popularity" | tr }}: {{ '%0.2f' % pkgbase.Popularity | float }}
First Submitted: {{ "First Submitted" | tr }}: {{ "%s" | tr | format(submitted.strftime("%Y-%m-%d %H:%M")) }}
Last Updated: {{ "Last Updated" | tr }}:{{ "%s" | tr | format(updated.strftime("%Y-%m-%d %H:%M")) }}