incorrect url for "add product variation" in admin templatetag

Issue #1137 resolved
slowpeels
created an issue

The correct URL should be /admin/configurable/productvariation/add/ and delete/

I've included a patch. Also is the TODO comment for django #7738 in this code still valid? Wasn't sure so I left it in.

Comments (6)

  1. Chris Moffitt repo owner

    Also, in looking at the patch, we should probably fix the urls so they aren't hard coded anymore. This link describes Django's syntax for doing so - http://docs.djangoproject.com/en/dev/ref/contrib/admin/#reversing-admin-urls

    Here's an inline of the proposed patch submitted by cra1g:

    diff -r 48722801011c satchmo/apps/product/templatetags/satchmo_product_admin.py
    --- a/satchmo/apps/product/templatetags/satchmo_product_admin.py	Sat May 01 14:42:56 2010 +0800
    +++ b/satchmo/apps/product/templatetags/satchmo_product_admin.py	Mon May 03 20:14:32 2010 -0300
    @@ -66,7 +66,7 @@
             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
    +            pv_url = '/admin/configurable/productvariation/%s/delete/' % product.pk
                 output += """
                 <tr>
                 <td>%s</td>
    @@ -80,7 +80,7 @@
                 #opt_pks = ','.join(opt_pks)
                 # TODO [NFA]: Blocked by Django ticket #7738.
                 opt_pks = ''
    -            add_url = ('/admin/product/productvariation/add/' +
    +            add_url = ('/admin/configurable/productvariation/add/' +
                     "?product=%s&parent=%s&options=%s" % (
                     configurableproduct.product.pk, configurableproduct.product.pk,
                     opt_pks))
    
    
    
  2. Tay Ray Chuan

    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

    2f66d517160d

  3. Tay Ray Chuan

    Merge in fix for admin urls

    References #1137.

    • commit 'c01d8c7': satchmo_product_admin: use reverse_admin_url() satchmo_utils.urlhelper: add reverse_admin_url() satchmo_utils.urlhelper: strip trailing whitespace satchmo_product_admin: don't wrap in () satchmo_product_admin: directly import reverse()

    96494e920590

  4. Log in to comment