[Patchew-devel] [PATCH] maintainers: clarify when the "Watch query" button would replace the current watched query

Paolo Bonzini posted 1 patch 2 years, 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/patchew-ci tags/patchew/20220222110044.173882-2-pbonzini@redhat.com
mods/maintainer.py             | 6 ++++--
www/templates/series-list.html | 2 ++
2 files changed, 6 insertions(+), 2 deletions(-)
[Patchew-devel] [PATCH] maintainers: clarify when the "Watch query" button would replace the current watched query
Posted by Paolo Bonzini 2 years, 1 month ago
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 mods/maintainer.py             | 6 ++++--
 www/templates/series-list.html | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/mods/maintainer.py b/mods/maintainer.py
index 8e05a9c..70d0ea5 100644
--- a/mods/maintainer.py
+++ b/mods/maintainer.py
@@ -182,8 +182,10 @@ class MaintainerModule(PatchewModule):
     def render_page_hook(self, request, context_data):
         if request.user.is_authenticated and context_data.get("is_search"):
             q = WatchedQuery.objects.filter(user=request.user).first()
-            if q and q.query == context_data.get("search"):
-                context_data["is_watched_query"] = True
+            if q:
+                context_data["has_watched_query"] = True
+                if q.query == context_data.get("search"):
+                    context_data["is_watched_query"] = True
 
     def www_view_watch_query(self, request):
         if not request.user.is_authenticated:
diff --git a/www/templates/series-list.html b/www/templates/series-list.html
index 83bde7f..27c0d9c 100644
--- a/www/templates/series-list.html
+++ b/www/templates/series-list.html
@@ -78,6 +78,8 @@
 {% if is_search %}
     {% if is_watched_query %}
         <p>Saved as my watched query</p>
+    {% elif has_watched_query %}
+        <button><a href="/watch-query/?q={{ search }}">Replace watched query</a></button>
     {% else %}
         <button><a href="/watch-query/?q={{ search }}">Watch query</a></button>
     {% endif %}
-- 
2.34.1

_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/patchew-devel