[PATCH] views: Update how patch counts are retrieved

Daniel Axtens dja at axtens.net
Fri Oct 21 08:30:59 AEDT 2016


Stephen Finucane <stephen at that.guru> writes:

> It's no longer possible to access 'Project.patch_set' as
> 'Project.submission_set' has replaced it. This was missed when the
> cover letter feature was merged, so resolve it now.
>
> Signed-off-by: Stephen Finucane <stephen at that.guru>
> Closes-bug: #54

Hmm. Evidently our tests didn't pick this up, which is a bit
disappointing. It would be good to check that all the views succeed,
both with and without data. I haven't been able to find any package or
trick to enumerate the views and test them automatically, which is a bit
of a shame, but failing that we could just test them manually...

Regards,
Daniel

> ---
>  patchwork/views/project.py | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/patchwork/views/project.py b/patchwork/views/project.py
> index 461618b..4c59c10 100644
> --- a/patchwork/views/project.py
> +++ b/patchwork/views/project.py
> @@ -25,6 +25,7 @@ from django.core import urlresolvers
>  from django.http import HttpResponseRedirect
>  from django.shortcuts import get_object_or_404, render
>  
> +from patchwork.models import Patch
>  from patchwork.models import Project
>  
>  
> @@ -44,13 +45,14 @@ def projects(request):
>  
>  def project(request, project_id):
>      project = get_object_or_404(Project, linkname=project_id)
> +    patches = Patch.objects.filter(project=project)
>  
>      context = {
>          'project': project,
>          'maintainers': User.objects.filter(
>              profile__maintainer_projects=project),
> -        'n_patches': project.patch_set.filter(archived=False).count(),
> -        'n_archived_patches': project.patch_set.filter(archived=True).count(),
> +        'n_patches': patches.filter(archived=False).count(),
> +        'n_archived_patches': patches.filter(archived=True).count(),
>          'enable_xmlrpc': settings.ENABLE_XMLRPC,
>      }
>      return render(request, 'patchwork/project.html', context)
> -- 
> 2.7.4
>
> _______________________________________________
> Patchwork mailing list
> Patchwork at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/patchwork


More information about the Patchwork mailing list