Commits

Tay Ray Chuan committed 2f66d51

satchmo_product_admin: use reverse_admin_url()

As a side-effect, the urls are now corrected.

Note that we delay the import of ProductVariation until
list_variations() is called, as it is not known if the user has enabled
the configurable product module.

Fixes #1137.

Reported-by: cra1g

Comments (0)

Files changed (1)

satchmo/apps/product/templatetags/satchmo_product_admin.py

 from django.template import Context, Template
 from django.utils.translation import ugettext_lazy as _
 from product import active_product_types
+from product.models import Product
+from satchmo_utils.urlhelper import reverse_admin_url
 
 register = template.Library()
 
 register.simple_tag(edit_subtypes)
 
 def list_variations(configurableproduct):
+    from product.modules.configurable.models import ProductVariation
+
     opts = configurableproduct.get_all_options()
     output = "{% load admin_modify adminmedia %}"
     output += "<table>"
 
         product = configurableproduct.get_product_from_options(p_opt)
         if product:
-            p_url = '/admin/product/product/%s/' % product.pk
-            pv_url = '/admin/product/productvariation/%s/delete/' % product.pk
+            p_url = reverse_admin_url(Product, 'change', args=(product.pk,))
+            pv_url = reverse_admin_url(ProductVariation, 'delete', args=(product.pk,))
             output += """
             <tr>
             <td>%s</td>
             #opt_pks = ','.join(opt_pks)
             # TODO [NFA]: Blocked by Django ticket #7738.
             opt_pks = ''
-            add_url = '/admin/product/productvariation/add/' + \
+            add_url = reverse_admin_url(ProductVariation, 'add') + \
                 "?product=%s&parent=%s&options=%s" % (
                 configurableproduct.product.pk, configurableproduct.product.pk,
                 opt_pks)