[PATCH 5/5] models: Trivial cleanup

Daniel Axtens dja at axtens.net
Thu Oct 13 10:38:15 AEDT 2016


Stephen Finucane <stephen at that.guru> writes:

> Signed-off-by: Stephen Finucane <stephen at that.guru>
> ---
>  patchwork/models.py | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/patchwork/models.py b/patchwork/models.py
> index 3abae3c..229b701 100644
> --- a/patchwork/models.py
> +++ b/patchwork/models.py
> @@ -20,7 +20,8 @@
>  
>  from __future__ import absolute_import
>  
> -from collections import Counter, OrderedDict
> +from collections import Counter
> +from collections import OrderedDict
>  import datetime
>  import hashlib
>  import random
> @@ -154,7 +155,8 @@ class UserProfile(models.Model):
>              qs = Patch.objects
>  
>          qs = qs.filter(archived=False).filter(
> -            delegate=self.user).filter(state__in=State.objects.filter(
> +            delegate=self.user).filter(
> +            state__in=State.objects.filter(
>                  action_required=True).values('pk').query)

Look, if we're going to change these lines, can we go the whole hog?
Here's a completely untested suggestion.

  permitted_states = State.objects.filter(delegate=self.user,
                                          action_required=true)
  qs.filter(archived=False,
            delegate=self.user,
            state__in=permitted_states).values('pk')

I think we can drop the .query at the end, but I haven't checked.

Regards,
Daniel
>          return qs
>  
> -- 
> 2.7.4
>
> _______________________________________________
> Patchwork mailing list
> Patchwork at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/patchwork


More information about the Patchwork mailing list