[PATCH 42/51] series: Add series to the TODO list

Damien Lespiau damien.lespiau at intel.com
Sat Sep 12 01:55:15 AEST 2015


Because Series object have a reviewer field, they are part of the list
of things to be on to TODO list, along with the patches where the user
is a delegate.

Signed-off-by: Damien Lespiau <damien.lespiau at intel.com>
---
 patchwork/models.py                           | 14 ++++++++++++--
 patchwork/templates/patchwork/profile.html    |  6 +++---
 patchwork/templates/patchwork/todo-list.html  | 18 ++++++++++++++++--
 patchwork/templates/patchwork/todo-lists.html |  2 +-
 patchwork/views/user.py                       |  7 +++++--
 templates/base.html                           |  2 +-
 6 files changed, 38 insertions(+), 11 deletions(-)

diff --git a/patchwork/models.py b/patchwork/models.py
index 1f13722..df9d85f 100644
--- a/patchwork/models.py
+++ b/patchwork/models.py
@@ -112,8 +112,8 @@ class UserProfile(models.Model):
     def sync_person(self):
         pass
 
-    def n_todo_patches(self):
-        return self.todo_patches().count()
+    def n_todo(self):
+        return self.todo_patches().count() + self.todo_series().count()
 
     def todo_patches(self, project = None):
 
@@ -130,6 +130,16 @@ class UserProfile(models.Model):
                          .values('pk').query)
         return qs
 
+    def todo_series(self, project = None):
+        # filter on project, if necessary
+        if project:
+            qs = Series.objects.filter(project = project)
+        else:
+            qs = Series.objects
+
+        qs = qs.filter(reviewer = self.user)
+        return qs
+
     def __unicode__(self):
         return self.name()
 
diff --git a/patchwork/templates/patchwork/profile.html b/patchwork/templates/patchwork/profile.html
index 116d6d6..d702a0e 100644
--- a/patchwork/templates/patchwork/profile.html
+++ b/patchwork/templates/patchwork/profile.html
@@ -25,10 +25,10 @@ Contributor to
 <div class="leftcol">
 <div class="box">
  <h2>Todo</h2>
-{% if user.profile.n_todo_patches %}
+{% if user.profile.n_todo %}
  <p>Your <a href="{% url 'patchwork.views.user.todo_lists' %}">todo
-  list</a> contains {{ user.profile.n_todo_patches }}
-  patch{{ user.profile.n_todo_patches|pluralize:"es" }}.</p>
+  list</a> contains {{ user.profile.n_todo }}
+  patch{{ user.profile.n_todo|pluralize:"es" }}.</p>
 {% else %}
  <p>Your todo list contains patches that have been delegated to you. You
   have no items in your todo list at present.</p>
diff --git a/patchwork/templates/patchwork/todo-list.html b/patchwork/templates/patchwork/todo-list.html
index b301901..c84992e 100644
--- a/patchwork/templates/patchwork/todo-list.html
+++ b/patchwork/templates/patchwork/todo-list.html
@@ -5,13 +5,27 @@
 {% block title %}{{ user }}'s todo list{% endblock %}
 {% block heading %}{{user}}'s todo list for {{ project.linkname }}{% endblock %}
 
+{% block headers %}
+<script language="JavaScript" type="text/javascript">
+$(function () {
+    pw.setup_series_list('#serieslist', '/api/1.0/self/reviews/');
+});
+</script>
+{% endblock %}
+
 {% block body %}
 
-<p>A Patchwork Todo-list contains patches that are assigned to you, and
-are in an "action required" state
+<p>A Patchwork Todo-list contains series and patches that are assigned to you,
+and are in an "action required" state
 ({% for state in action_required_states %}{% if forloop.last and not forloop.first %} or {% endif %}{{ state }}{% if not forloop.last and not forloop.first %}, {%endif %}{% endfor %}), and are not archived.
 </p>
 
+<h2>Series</h2>
+
+{% include "patchwork/series-list-table.html" %}
+
+<h2>Patches</h2>
+
 {% include "patchwork/patch-list.html" %}
 
 {% endblock %}
diff --git a/patchwork/templates/patchwork/todo-lists.html b/patchwork/templates/patchwork/todo-lists.html
index e268160..cd469a0 100644
--- a/patchwork/templates/patchwork/todo-lists.html
+++ b/patchwork/templates/patchwork/todo-lists.html
@@ -18,7 +18,7 @@
   <td><a
    href="{% url 'patchwork.views.user.todo_list' project_id=todo_list.project.linkname %}"
     >{{ todo_list.project.name }}</a></td>
-  <td class="numberformat">{{ todo_list.n_patches }}</td>
+  <td class="numberformat">{{ todo_list.n_items }}</td>
  </tr>
 {% endfor %}
 </table>
diff --git a/patchwork/views/user.py b/patchwork/views/user.py
index 126ecc9..3f02aff 100644
--- a/patchwork/views/user.py
+++ b/patchwork/views/user.py
@@ -185,10 +185,13 @@ def todo_lists(request):
 
     for project in Project.objects.all():
         patches = request.user.profile.todo_patches(project = project)
-        if not patches.count():
+        series = request.user.profile.todo_series(project=project)
+
+        n_items = patches.count() + series.count()
+        if not n_items:
             continue
 
-        todo_lists.append({'project': project, 'n_patches': patches.count()})
+        todo_lists.append({'project': project, 'n_items': n_items})
 
     if len(todo_lists) == 1:
         return todo_list(request, todo_lists[0]['project'].linkname)
diff --git a/templates/base.html b/templates/base.html
index 18c3ef6..a03459f 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -59,7 +59,7 @@
 {% endif %}
 {% if user.is_authenticated %}
      <li><a href="{% url 'patchwork.views.user.todo_lists' %}">Todo
-      <span class="badge">{{ user.profile.n_todo_patches }}</span></a>
+      <span class="badge">{{ user.profile.n_todo }}</span></a>
      </li>
      <li><a href="{% url 'patchwork.views.bundle.bundles' %}">Bundles</a></li>
 {% if user.is_staff %}
-- 
2.1.0



More information about the Patchwork mailing list