Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix broken links with page promotions #373

Closed
wants to merge 3 commits into from

3 participants

@elbaschid

The urlencode links are not working properly. This might be an Apache configuration issue but the provided change is a slightly cleaner solution. Please let me know what you think.

@codeinthehole

Your right that is normally an Apache issue that prevents this working. I've written about this previously:
http://codeinthehole.com/writing/django-nginx-wsgi-and-encoded-slashes/

I presume that you've tested this change in Apache and it works ok. Have you tested it with nginx in front of apache too?

@elbaschid

That's good to know that it actually is a configuration thing. Thanks for the link and the detailed explanation in the post.

About my proposed changes in this PR: we are currently running this as a patch on a production site with Apache behind nginx. So far, everything works fine and we didn't have any problems. And this is without any additional modifications to either of them.
I am also using the same regex with fancypages and haven't had any issues there. The demo site is currently also running nginx and Apache.

@codeinthehole

Bumping to 0.6 for now. This isn't urgent as I don't have this problem on existing Oscar sites.

I'd like to get Vagrant set up to test Nginx/Apache configs, which I've ticketed separately: #602

Once that's done - it will be easy to check this kind of pull request where the issue is around the apache config rather than the python code.

@michelts

I use the nginx + uwsgi pair to publish the store. The nginx compress adjacent slashes by default. You must unset it with the option merge_slashes (i.e merge_slashes off). Put it in the server block (not the location block).

It worked in my environment. If this still be a problem in other environments, we can consider to use GET parameters instead of url args...

@codeinthehole

Have merged these changes onto master. Will certainly consider using GET params though to avoid this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
2  oscar/apps/dashboard/promotions/app.py
@@ -34,7 +34,7 @@ def get_urls(self):
urlpatterns = patterns('',
url(r'^$', self.list_view.as_view(), name='promotion-list'),
url(r'^pages/$', self.page_list.as_view(), name='promotion-list-by-page'),
- url(r'^pages/(?P<path>.+)/$', self.page_detail.as_view(), name='promotion-list-by-url'),
+ url(r'^page/(?P<path>/([\w-]+(/[\w-]+)*/)?)$', self.page_detail.as_view(), name='promotion-list-by-url'),
url(r'^create/$',
self.create_redirect_view.as_view(),
name='promotion-create-redirect'),
View
3  oscar/apps/dashboard/promotions/views.py
@@ -291,8 +291,7 @@ def form_valid(self, form):
return HttpResponseRedirect(self.get_success_url())
ctx = self.get_context_data(product_formset=product_formset)
- return self.render_response(ctx)
-
+ return self.render_to_response(ctx)
# ============
View
2  oscar/templates/oscar/dashboard/promotions/form.html
@@ -61,7 +61,7 @@
{% csrf_token %}
<input type="hidden" name="action" value="remove_from_page" />
<input type="hidden" name="pagepromotion_id" value="{{ link.id }}" />
- <a href="{% url dashboard:promotion-list-by-url link.page_url|urlencode:"" %}" class="btn btn-info">{% trans "View all blocks on this page" %}</a>
+ <a href="{% url dashboard:promotion-list-by-url link.page_url %}" class="btn btn-info">{% trans "View all blocks on this page" %}</a>
<button class="btn btn-danger btn-small" type="submit">{% trans "Remove from page" %}</button>
</form>
</td>
View
2  oscar/templates/oscar/dashboard/promotions/pagepromotion_list.html
@@ -52,7 +52,7 @@
<td>{{ page.page_url }}</td>
<td>{{ page.freq }}</td>
<td>
- <a href="{% url dashboard:promotion-list-by-url page.page_url|urlencode:"" %}" class="btn btn-success">{% trans "Edit" %}</a>
+ <a href="{% url dashboard:promotion-list-by-url page.page_url %}" class="btn btn-success">{% trans "Edit" %}</a>
</td>
<td> </td>
</tr>
Something went wrong with that request. Please try again.