Browse files

Merge pull request #294 from groovecoder/trailing-slash-766313

Trailing slash 766313
  • Loading branch information...
2 parents f8a100d + 1901a7e commit 6d8f9833ac349478ac0572e8cee0b9844a79ba62 @darkwing darkwing committed Jun 20, 2012
Showing with 37 additions and 34 deletions.
  1. +26 −24 apps/demos/urls.py
  2. +1 −1 apps/devmo/urls.py
  3. +5 −5 apps/users/tests/test_helpers.py
  4. +5 −4 urls.py
View
50 apps/demos/urls.py
@@ -1,9 +1,5 @@
from django.conf.urls.defaults import *
-from django.views.generic.list_detail import object_list
-
-from demos.models import Submission
-
from .feeds import RecentSubmissionsFeed, FeaturedSubmissionsFeed
from .feeds import TagSubmissionsFeed, ProfileSubmissionsFeed
from .feeds import SearchSubmissionsFeed
@@ -15,10 +11,12 @@
urlpatterns = patterns('demos.views',
url(r'^$', 'home', name='demos'),
-
+
url(r'^devderby/?$', 'devderby_landing', name='demos_devderby_landing'),
- url(r'^devderby/(?P<year>\d\d\d\d)/(?P<month>[\w]+)/$', 'devderby_by_date', name='demos_devderby_by_date'),
- url(r'^devderby/tag/(?P<tag>[^/]+)/$', 'devderby_tag', name='demos_devderby_tag'),
+ url(r'^devderby/(?P<year>\d\d\d\d)/(?P<month>[\w]+)/?$',
+ 'devderby_by_date', name='demos_devderby_by_date'),
+ url(r'^devderby/tag/(?P<tag>[^/]+)/?$', 'devderby_tag',
+ name='demos_devderby_tag'),
url(r'^devderby/rules/?$', 'devderby_rules', name='demos_devderby_rules'),
url(r'^terms', 'terms', name='demos_terms'),
@@ -29,35 +27,39 @@
url(r'^detail/(?P<slug>[^/]+)/like$', 'like', name='demos_like'),
url(r'^detail/(?P<slug>[^/]+)/unlike$', 'unlike', name='demos_unlike'),
url(r'^detail/(?P<slug>[^/]+)/flag$', 'flag', name='demos_flag'),
- url(r'^detail/(?P<slug>[^/]+)/download$', 'download', name='demos_download'),
+ url(r'^detail/(?P<slug>[^/]+)/download$', 'download',
+ name='demos_download'),
url(r'^detail/(?P<slug>[^/]+)/launch$', 'launch', name='demos_launch'),
url(r'^detail/(?P<slug>[^/]+)/edit$', 'edit', name='demos_edit'),
url(r'^detail/(?P<slug>[^/]+)/delete$', 'delete', name='demos_delete'),
- url(r'^detail/(?P<slug>[^/]+)/comment/$',
+ url(r'^detail/(?P<slug>[^/]+)/comment/$',
'new_comment', name='demos_new_comment'),
- url(r'^detail/(?P<slug>[^/]+)/comment/(?P<parent_id>\d+)/$',
+ url(r'^detail/(?P<slug>[^/]+)/comment/(?P<parent_id>\d+)/$',
'new_comment', name='demos_new_reply'),
- url(r'^detail/(?P<slug>[^/]+)/comment/(?P<object_id>\d+)/delete/$',
+ url(r'^detail/(?P<slug>[^/]+)/comment/(?P<object_id>\d+)/delete/$',
'delete_comment', name='demos_delete_comment'),
- url(r'^detail/(?P<slug>[^/]+)/hide$', 'hideshow', dict( hide=True ), name='demos_hide'),
- url(r'^detail/(?P<slug>[^/]+)/show$', 'hideshow', dict( hide=False ), name='demos_show'),
+ url(r'^detail/(?P<slug>[^/]+)/hide$', 'hideshow', dict(hide=True),
+ name='demos_hide'),
+ url(r'^detail/(?P<slug>[^/]+)/show$', 'hideshow', dict(hide=False),
+ name='demos_show'),
- url(r'^search/$', 'search', name="demos_search"),
- url(r'^all/$', 'all', name='demos_all'),
- url(r'^tag/(?P<tag>[^/]+)/$', 'tag', name='demos_tag'),
- url(r'^profile/(?P<username>[^/]+)/?$', 'profile_detail', name="demos_profile_detail"),
+ url(r'^search/?$', 'search', name="demos_search"),
+ url(r'^all/?$', 'all', name='demos_all'),
+ url(r'^tag/(?P<tag>[^/]+)/?$', 'tag', name='demos_tag'),
+ url(r'^profile/(?P<username>[^/]+)/?$', 'profile_detail',
+ name="demos_profile_detail"),
- url(r'feeds/(?P<format>[^/]+)/all/', RecentSubmissionsFeed(),
+ url(r'feeds/(?P<format>[^/]+)/all/', RecentSubmissionsFeed(),
name="demos_feed_recent"),
- url(r'feeds/(?P<format>[^/]+)/featured/', FeaturedSubmissionsFeed(),
+ url(r'feeds/(?P<format>[^/]+)/featured/', FeaturedSubmissionsFeed(),
name="demos_feed_featured"),
- url(r'feeds/(?P<format>[^/]+)/search/$', SearchSubmissionsFeed(),
+ url(r'feeds/(?P<format>[^/]+)/search/?$', SearchSubmissionsFeed(),
name="demos_feed_search"),
- url(r'feeds/(?P<format>[^/]+)/tag/(?P<tag>[^/]+)/$', TagSubmissionsFeed(),
+ url(r'feeds/(?P<format>[^/]+)/tag/(?P<tag>[^/]+)/?$', TagSubmissionsFeed(),
name="demos_feed_tag"),
- url(r'feeds/(?P<format>[^/]+)/profile/(?P<username>[^/]+)/?$', ProfileSubmissionsFeed(),
- name="demos_feed_profile"),
-
+ url(r'feeds/(?P<format>[^/]+)/profile/(?P<username>[^/]+)/?$',
+ ProfileSubmissionsFeed(), name="demos_feed_profile"),
+
)
urlpatterns += patterns('',
(r'^comments/', include('threadedcomments.urls')),
View
2 apps/devmo/urls.py
@@ -3,7 +3,7 @@
urlpatterns = patterns('devmo.views',
url(r'^events/?$', 'events', name='events'),
- url(r'^profiles/(?P<username>[^/]+)/$', 'profile_view',
+ url(r'^profiles/(?P<username>[^/]+)/?$', 'profile_view',
name="devmo_profile_view"),
url(r'^profiles/(?P<username>[^/]+)/edit$', 'profile_edit',
name="devmo_profile_edit"),
View
10 apps/users/tests/test_helpers.py
@@ -1,13 +1,11 @@
import urllib
-import logging
from hashlib import md5
from django.conf import settings
from django.contrib.auth.models import User
from jinja2 import Markup
from nose.tools import eq_, ok_
-from nose.plugins.attrib import attr
from pyquery import PyQuery as pq
from sumo.tests import TestCase
@@ -25,10 +23,12 @@ def setUp(self):
self.u = User.objects.get(username=u'testuser')
def test_profile_url(self):
- eq_(u'/profiles/testuser/', profile_url(self.u))
+ eq_(u'/profiles/testuser', profile_url(self.u))
def test_profile_default_gravatar(self):
- ok_(urllib.urlencode({'d': settings.DEFAULT_AVATAR}) in profile_avatar(self.u), "Bad default avatar: %s" % profile_avatar(self.u))
+ d_param = urllib.urlencode({'d': settings.DEFAULT_AVATAR})
+ ok_(d_param in profile_avatar(self.u),
+ "Bad default avatar: %s" % profile_avatar(self.u))
def test_profile_avatar(self):
self.u.email = 'test@test.com'
@@ -59,5 +59,5 @@ def test_user_list(self):
fragment = pq(list)
eq_(5, len(fragment('a')))
a = fragment('a')[4]
- assert a.attrib['href'].endswith('testuser3/')
+ assert a.attrib['href'].endswith('testuser3')
eq_('testuser3', a.text)
View
9 urls.py
@@ -16,11 +16,11 @@
('', include('landing.urls')),
('', include('devmo.urls')),
(r'^logout/$', 'dekicompat.views.logout'),
- (r'^demos/', include('demos.urls')),
+ (r'^demos/?', include('demos.urls')),
# Django admin:
- (r'^admin/', include('smuggler.urls')),
- (r'^admin/', include(admin.site.urls)),
+ (r'^admin/?', include('smuggler.urls')),
+ (r'^admin/?', include(admin.site.urls)),
(r'^search', include('search.urls')),
#(r'^forums', include('forums.urls')),
@@ -31,7 +31,7 @@
# Docs landing page and next-gen kuma wiki
('', include('docs.urls')),
(r'^docs', include('wiki.urls')),
-
+
#(r'^gallery', include('gallery.urls')),
#(r'^army-of-awesome', include('customercare.urls')),
#(r'^chat', include('chat.urls')),
@@ -59,6 +59,7 @@
(r'^(?P<path>.*)$', 'wiki.views.mindtouch_to_kuma_redirect'),
)
+
# Handle 404 and 500 errors
def _error_page(request, status):
"""Render error pages with jinja2."""

0 comments on commit 6d8f983

Please sign in to comment.