[PATCH 2/5] models: Remove Bundle.n_patches
Daniel Axtens
dja at axtens.net
Thu Oct 13 10:14:03 AEDT 2016
Stephen Finucane <stephen at that.guru> writes:
> It doesn't really do much for us. Less LOC = win.
>
Reviewed-by: Daniel Axtens <dja at axtens.net>
> Signed-off-by: Stephen Finucane <stephen at that.guru>
> ---
> patchwork/models.py | 3 ---
> patchwork/templates/patchwork/bundles.html | 2 +-
> patchwork/views/xmlrpc.py | 2 +-
> 3 files changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/patchwork/models.py b/patchwork/models.py
> index 2a98eff..3c554af 100644
> --- a/patchwork/models.py
> +++ b/patchwork/models.py
> @@ -570,9 +570,6 @@ class Bundle(models.Model):
> patches = models.ManyToManyField(Patch, through='BundlePatch')
> public = models.BooleanField(default=False)
>
> - def n_patches(self):
> - return self.patches.all().count()
> -
> def ordered_patches(self):
> return self.patches.order_by('bundlepatch__order')
>
> diff --git a/patchwork/templates/patchwork/bundles.html b/patchwork/templates/patchwork/bundles.html
> index 2eebd26..45bdec5 100644
> --- a/patchwork/templates/patchwork/bundles.html
> +++ b/patchwork/templates/patchwork/bundles.html
> @@ -27,7 +27,7 @@
> <a href="{{ bundle.public_url }}">{{ bundle.public_url }}</a>
> {% endif %}
> </td>
> - <td style="text-align: right">{{ bundle.n_patches }}</td>
> + <td style="text-align: right">{{ bundle.patches.count }}</td>
> <td style="text-align: center;"><a
> href="{% url 'bundle-mbox' username=bundle.owner.username bundlename=bundle.name %}"
> ><img src="{% static "images/16-em-down.png" %}" width="16" height="16" alt="download"
> diff --git a/patchwork/views/xmlrpc.py b/patchwork/views/xmlrpc.py
> index cfb80d3..30829e7 100644
> --- a/patchwork/views/xmlrpc.py
> +++ b/patchwork/views/xmlrpc.py
> @@ -311,7 +311,7 @@ def bundle_to_dict(obj):
> return {
> 'id': obj.id,
> 'name': obj.name,
> - 'n_patches': obj.n_patches(),
> + 'n_patches': obj.patches.count(),
> 'public_url': obj.public_url(),
> }
>
> --
> 2.7.4
>
> _______________________________________________
> Patchwork mailing list
> Patchwork at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/patchwork
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 859 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/patchwork/attachments/20161013/39a8bb32/attachment.sig>
More information about the Patchwork
mailing list