From: Fam Zheng <famz@redhat.com>
This button will update the search query used to automatically populate
the user's 'watched' queue.
Signed-off-by: Fam Zheng <famz@redhat.com>
---
mods/maintainer.py | 17 +++++++++++++++++
www/templates/series-list.html | 8 ++++++++
2 files changed, 25 insertions(+)
diff --git a/mods/maintainer.py b/mods/maintainer.py
index 541d6f3..54738ec 100644
--- a/mods/maintainer.py
+++ b/mods/maintainer.py
@@ -100,6 +100,22 @@ class MaintainerModule(PatchewModule):
self._drop_from_queue(request.user, m, queue)
return HttpResponseRedirect(request.META.get('HTTP_REFERER'))
+ 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
+
+ def www_view_watch_query(self, request):
+ if not request.user.is_authenticated:
+ raise PermissionDenied()
+ query = request.GET.get("q")
+ if not query:
+ return HttpResponseBadRequest("Invalid query")
+ WatchedQuery.objects.update_or_create(defaults={"query": query},
+ user=request.user)
+ return HttpResponseRedirect(request.META.get('HTTP_REFERER'))
+
def www_url_hook(self, urlpatterns):
urlpatterns.append(url(r"^mark-as-merged/(?P<message_id>.*)/",
self.www_view_mark_as_merged,
@@ -122,6 +138,7 @@ class MaintainerModule(PatchewModule):
urlpatterns.append(url(r"^drop-from-queue/(?P<queue>[^/]*)/(?P<message_id>.*)/",
self.www_view_drop_from_queue,
name="drop-from-queue"))
+ urlpatterns.append(url(r"^watch-query/", self.www_view_watch_query))
def prepare_message_hook(self, request, message, detailed):
if not detailed or not request.user.is_authenticated:
diff --git a/www/templates/series-list.html b/www/templates/series-list.html
index 8a29f98..6c77d47 100644
--- a/www/templates/series-list.html
+++ b/www/templates/series-list.html
@@ -74,6 +74,14 @@
</div>
{% endif %}
+{% if is_search %}
+ {% if is_watched_query %}
+ <p>Saved as my watched query</p>
+ {% else %}
+ <button><a href="/watch-query/?q={{ search }}">Watch query</a></button>
+ {% endif %}
+{% endif %}
+
<nav>
<ul class="pagination pagination-sm">
{% for i in page_links %}
--
2.17.2
_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel