[PATCH 4/5] views: Stop using Bundle.public_url

Stephen Finucane stephen at that.guru
Sat Feb 25 23:05:23 AEDT 2017


We now have 'get_mbox_url' which is consistent with patches. Let's drop
the older one.

Signed-off-by: Stephen Finucane <stephen at that.guru>
Cc: Daniel Axtens <dja at axtens.net>
---
 patchwork/models.py                        | 13 -------------
 patchwork/templates/patchwork/bundles.html |  5 ++---
 patchwork/views/xmlrpc.py                  |  2 +-
 3 files changed, 3 insertions(+), 17 deletions(-)

diff --git a/patchwork/models.py b/patchwork/models.py
index 214b75c..06911b7 100644
--- a/patchwork/models.py
+++ b/patchwork/models.py
@@ -27,8 +27,6 @@ import re
 
 from django.contrib.auth.models import User
 from django.conf import settings
-from django.contrib.sites.models import Site
-from django.core.urlresolvers import reverse
 from django.db import models
 from django.utils.encoding import python_2_unicode_compatible
 from django.utils.functional import cached_property
@@ -721,17 +719,6 @@ class Bundle(models.Model):
         return BundlePatch.objects.create(bundle=self, patch=patch,
                                           order=max_order + 1)
 
-    def public_url(self):
-        if not self.public:
-            return None
-        site = Site.objects.get_current()
-        return 'http://%s%s' % (site.domain,
-                                reverse('bundle-detail',
-                                        kwargs={
-                                            'username': self.owner.username,
-                                            'bundlename': self.name
-                                        }))
-
     def is_editable(self, user):
         if not user.is_authenticated():
             return False
diff --git a/patchwork/templates/patchwork/bundles.html b/patchwork/templates/patchwork/bundles.html
index 83e1bd0..9e225ea 100644
--- a/patchwork/templates/patchwork/bundles.html
+++ b/patchwork/templates/patchwork/bundles.html
@@ -24,12 +24,11 @@
   <td>{{ bundle.project.linkname }}</td>
   <td>
    {% if bundle.public %}
-    <a href="{{ bundle.public_url }}">{{ bundle.public_url }}</a>
+    <a href="{{ bundle.get_mbox_url }}">{{ bundle.get_mbox_url }}</a>
    {% endif %}
   </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 %}"
+  <td style="text-align: center;"><ahref="{{ bundle.get_mbox_url }}"
    ><span class="glyphicon glyphicon-download-alt"></span></a></td>
   <td style="text-align: center;">
    <form method="post"
diff --git a/patchwork/views/xmlrpc.py b/patchwork/views/xmlrpc.py
index 66e908e..bb8b729 100644
--- a/patchwork/views/xmlrpc.py
+++ b/patchwork/views/xmlrpc.py
@@ -314,7 +314,7 @@ def bundle_to_dict(obj):
         'id': obj.id,
         'name': obj.name,
         'n_patches': obj.patches.count(),
-        'public_url': obj.public_url(),
+        'public_url': obj.get_mbox_url(),
     }
 
 
-- 
2.9.3



More information about the Patchwork mailing list