From patchwork Mon Apr 4 21:00:05 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guilherme Salgado X-Patchwork-Id: 89709 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id CF116B6FC4 for ; Tue, 5 Apr 2011 07:00:15 +1000 (EST) Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by ozlabs.org (Postfix) with ESMTP id 2BA20B6FBD for ; Tue, 5 Apr 2011 07:00:12 +1000 (EST) Received: from youngberry.canonical.com ([91.189.89.112]) by adelie.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1Q6qsc-0007om-EY for ; Mon, 04 Apr 2011 21:00:10 +0000 Received: from [187.126.166.24] (helo=feioso) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1Q6qsb-0002XH-QJ for patchwork@lists.ozlabs.org; Mon, 04 Apr 2011 21:00:10 +0000 Received: by feioso (Postfix, from userid 1001) id 41EA6424D8; Mon, 4 Apr 2011 18:00:06 -0300 (BRT) Subject: [RFC] A new page listing the user's patches that are waiting for feedback From: Guilherme Salgado To: patchwork Date: Mon, 04 Apr 2011 18:00:05 -0300 Message-ID: <1301950805.2613.68.camel@feioso> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org 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, 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[^/]+)/$', '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
+

Patches you submitted

+{% if user.get_profile.submitted_patches_waiting_feedback.count %} +

There are + {{ user.get_profile.submitted_patches_waiting_feedback.count }} patches submitted by you + that haven't been reviewed yet.

+{% else %} +

There are no patches submitted by you that haven't been reviewed.

+{% endif %} +
+ +

Linked email addresses

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 %} + +

TODO

+ +{% include "patchwork/patch-list.html" %} + +{% endblock %}