This new page lists the user's queues and the patches added to them.
Signed-off-by: Fam Zheng <famz@redhat.com>
---
mods/maintainer.py | 17 ++++++++
www/templates/base.html | 3 ++
www/templates/my-queues.html | 82 ++++++++++++++++++++++++++++++++++++
3 files changed, 102 insertions(+)
create mode 100644 www/templates/my-queues.html
diff --git a/mods/maintainer.py b/mods/maintainer.py
index a92995f..665b074 100644
--- a/mods/maintainer.py
+++ b/mods/maintainer.py
@@ -14,6 +14,7 @@ from django.http import Http404, HttpResponseRedirect, HttpResponseBadRequest
from django.urls import reverse
from mod import PatchewModule
from api.models import Message, Queue, WatchedQuery
+from django.shortcuts import render
from api.search import SearchEngine
from event import register_handler
@@ -123,6 +124,21 @@ class MaintainerModule(PatchewModule):
self._drop_from_queue(request.user, m, queue)
return HttpResponseRedirect(request.META.get('HTTP_REFERER'))
+ def www_view_my_queues(self, request):
+ if not request.user.is_authenticated:
+ raise PermissionDenied()
+ data = {}
+ for i in Queue.objects.filter(message__is_patch=True,
+ user=request.user).\
+ order_by("message__project", "name", "message__date"):
+ pn = i.message.project.name
+ qn = i.name
+ data.setdefault(pn, {})
+ data[pn].setdefault(qn, [])
+ data[pn][qn].append(i.message)
+
+ return render(request, "my-queues.html", context={"projects": data})
+
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()
@@ -161,6 +177,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"^my-queues/", self.www_view_my_queues))
urlpatterns.append(url(r"^watch-query/", self.www_view_watch_query))
def prepare_message_hook(self, request, message, detailed):
diff --git a/www/templates/base.html b/www/templates/base.html
index 89dabcf..60e6178 100644
--- a/www/templates/base.html
+++ b/www/templates/base.html
@@ -74,6 +74,9 @@ crossorigin="anonymous"/>
Hi {{ user.username }} <span class="caret"></span>
</button>
<ul class="dropdown-menu">
+ {% if request.user.is_authenticated %}
+ <li><a href="/my-queues" target="blank">My queues</a></li>
+ {% endif %}
{% if request.user.is_staff %}
<li><a href="/admin" target="blank">Admin</a></li>
{% endif %}
diff --git a/www/templates/my-queues.html b/www/templates/my-queues.html
new file mode 100644
index 0000000..627dc5a
--- /dev/null
+++ b/www/templates/my-queues.html
@@ -0,0 +1,82 @@
+{% extends 'base.html' %}
+
+{% block header %}
+<link rel="stylesheet" href="/static/css/series-detail.css">
+<link rel="stylesheet" href="/static/highlight/default.css">
+<script src="/static/highlight/highlight.pack.js"></script>
+<link rel="stylesheet" href="/static/css/colorbox.css">
+<script src="/static/js/jquery.colorbox-min.js"></script>
+{% endblock %}
+
+{% block title %}My queues{% endblock %}
+
+{% block content %}
+
+<div class="series-detail" id="top"></div>
+
+<div class="col-lg-12">
+
+<div id="pre-fixed"></div>
+<div class="col-lg-2">
+ <div id="fixed" class="list-group">
+ <a href="#" class="list-group-item" id="btn-expand-all">Expand all</a>
+ <a href="#" class="list-group-item" id="btn-fold-all">Fold all</a>
+ </div>
+</div>
+
+{% if projects %}
+{% for p, queues in projects.items %}
+
+ <div class="col-lg-10">
+ {% for qn, msgs in queues.items %}
+ <h3>Queue: {{ qn }} [{{ p }}]</h3>
+ <ul class="panel" id="patches">
+ {% for patch in msgs %}
+ <li><a href="/{{ p }}/{{ patch.get_series_head.message_id }}/">
+ <span class="fa fa-lg {% if patch.has_replies %}fa-comment-o{% else %}fa-ellipsis-v{% endif %}"></span>
+ {{ patch.subject }}
+ </a></li>
+ {% endfor %}
+ </ul>
+ {% endfor %}
+ </div>
+
+{% endfor %}
+{% else %}
+<p>You haven't created any queue</p>
+{% endif %}
+
+<script type="text/javascript">
+
+function main() {
+ $(".timestamp").each(function (i, o) {
+ $(o).attr("title", new Date(1000 * $(o).attr("title")));
+ });
+ $("#btn-expand-all").click(function () {
+ $(".panel-collapse").collapse("show");
+ });
+ $("#btn-fold-all").click(function () {
+ $(".panel-collapse").collapse("hide");
+ });
+ $(document).ready(function() {
+ $('pre code').each(function(i, block) {
+ hljs.highlightBlock(block);
+ });
+ $(".cbox-log").colorbox({width:"90%", height: "80%", iframe: true,
+ href: function() {
+ link = $(this).data('link');
+ return link ? link : $(this).attr('href');
+ }, onComplete: function() {
+ setTimeout(function() {
+ $('.cboxIframe')[0].contentWindow.focus();
+ }, 400);
+ }});
+ });
+ add_fixed_scroll_events();
+}
+
+$(main);
+
+</script>
+
+{% endblock %}
--
2.17.2
_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel