Hi there,

I've been working on a new patch-list page which includes all patches
submitted by the logged in user (in fact by any Person linked to the
logged in user) that are still waiting for feedback
(state.action_required==True).  

The reason I've worked on this is because in Linaro we'd benefit from
having a single place where users can see all their patches that haven't
gotten feedback yet, without having to go to the patch-list of every
project they might have contributed and filtering the patches there by
submitter.  I think other users might find this useful as well, so here
it is.

Notice that this is still a work in progress and, AFAIK, this is the
first cross-project patch list, but it uses the same underlying
infrastructure used by other patch lists, so some things there may not
work (cross-project bundling, for instance). Also, the initial state of
the filters does not reflect reality and this seems tricky to do as you
can't use the UI to filter on multiple submitters, but I don't think
this is that big a deal.

So, is there interest in adding such a page to Patchwork?  If so, is the
direction I'm going reasonable or should I be taking a different
approach to implement it?

Cheers,

-- 
Guilherme Salgado <https://launchpad.net/~salgado>
diff --git a/apps/patchwork/models.py b/apps/patchwork/models.py
index e4df2c5..7e2905d 100644
--- a/apps/patchwork/models.py
+++ b/apps/patchwork/models.py
@@ -100,6 +100,11 @@ class UserProfile(models.Model):
     def n_todo_patches(self):
         return self.todo_patches().count()
 
+    def submitted_patches_waiting_feedback(self):
+        people = Person.objects.filter(user=self)
+        states = State.objects.filter(action_required=True)
+        return Patch.objects.filter(submitter__in=people, state__in=states)
+
     def todo_patches(self, project = None):
 
         # filter on project, if necessary
diff --git a/apps/patchwork/tests/models.py b/apps/patchwork/tests/models.py
new file mode 100644
index 0000000..99d9d20
--- /dev/null
+++ b/apps/patchwork/tests/models.py
@@ -0,0 +1,37 @@
+
+from django.test import TestCase
+
+from patchwork.models import State
+from patchwork.tests.factory import ObjectFactory
+
+
+class UserProfileTestCase(TestCase):
+
+    def setUp(self):
+        super(UserProfileTestCase, self).setUp()
+        self.factory = ObjectFactory()
+
+    def test_submitted_patches_waiting_feedback(self):
+        # Create two people linked to the same user.
+        person = self.factory.makePerson(is_user=True)
+        profile = person.user.get_profile()
+        person2 = self.factory.makePerson(is_user=False)
+        person2.user = person.user
+        person2.save()
+
+        # Create 4 patches, where the first three have a person linked to our
+        # newly created user as the submitter but only the first two ones are
+        # in a state that needs action.
+        patch1 = self.factory.makePatch(submitter=person)
+        patch2 = self.factory.makePatch(submitter=person2)
+        patch3 = self.factory.makePatch(submitter=person2)
+        patch3.state = State.objects.get(name='Accepted')
+        patch3.save()
+        patch4 = self.factory.makePatch()
+
+        # Here we see that UserProfile.submitted_patches_waiting_feedback()
+        # only returns the two patches that are in a state that requires
+        # action and that have been submitted by a person linked to that
+        # profile.
+        self.assertEquals([patch1, patch2],
+                          list(profile.submitted_patches_waiting_feedback()))
diff --git a/apps/patchwork/urls.py b/apps/patchwork/urls.py
index b49b4e1..b5855da 100644
--- a/apps/patchwork/urls.py
+++ b/apps/patchwork/urls.py
@@ -33,6 +33,7 @@ urlpatterns = patterns('',
 
     # logged-in user stuff
     (r'^user/$', 'patchwork.views.user.profile'),
+    (r'^user/submitted/$', 'patchwork.views.user.submitted_patches_list'),
     (r'^user/todo/$', 'patchwork.views.user.todo_lists'),
     (r'^user/todo/(?P<project_id>[^/]+)/$', 'patchwork.views.user.todo_list'),
 
diff --git a/apps/patchwork/views/user.py b/apps/patchwork/views/user.py
index 1ae3c2d..dd55cf7 100644
--- a/apps/patchwork/views/user.py
+++ b/apps/patchwork/views/user.py
@@ -109,6 +109,18 @@ def unlink(request, person_id):
 
 
 @login_required
+def submitted_patches_list(request):
+    profile = request.user.get_profile()
+    patches = profile.submitted_patches_waiting_feedback()
+
+    context = generic_list(
+        request, None, 'patchwork.views.user.submitted_patches_list',
+        patches=patches)
+
+    return render_to_response('patchwork/submitted-list.html', context)
+
+
+@login_required
 def todo_lists(request):
     todo_lists = []
 
diff --git a/templates/patchwork/profile.html b/templates/patchwork/profile.html
index 44df921..be65211 100644
--- a/templates/patchwork/profile.html
+++ b/templates/patchwork/profile.html
@@ -36,6 +36,17 @@ Contributor to
 </div>
 
 <div class="box">
+ <h2>Patches you submitted</h2>
+{% if user.get_profile.submitted_patches_waiting_feedback.count %}
+ <p>There are <a href="{% url patchwork.views.user.submitted_patches_list %}">
+ {{ user.get_profile.submitted_patches_waiting_feedback.count }} patches submitted by you</a>
+ that haven't been reviewed yet.</p>
+{% else %}
+ <p>There are no patches submitted by you that haven't been reviewed.</p>
+{% endif %}
+</div>
+
+<div class="box">
 <h2>Linked email addresses</h2>
 <p>The following email addresses are associated with this patchwork account.
 Adding alternative addresses allows patchwork to group contributions that
diff --git a/templates/patchwork/submitted-list.html b/templates/patchwork/submitted-list.html
new file mode 100644
index 0000000..51c8603
--- /dev/null
+++ b/templates/patchwork/submitted-list.html
@@ -0,0 +1,14 @@
+{% extends "base.html" %}
+
+{% load person %}
+
+{% block title %}{{ user }}'s submitted patches{% endblock %}
+{% block heading %}{{user}}'s submitted patches{% endblock %}
+
+{% block body %}
+
+<p>TODO</p>
+
+{% include "patchwork/patch-list.html" %}
+
+{% endblock %}

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
Patchwork mailing list
[email protected]
https://lists.ozlabs.org/listinfo/patchwork

Reply via email to