Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
Merge pull request #291 from groovecoder/trailing-slash-766313
Browse files Browse the repository at this point in the history
Trailing slash 766313
  • Loading branch information
darkwing committed Jun 20, 2012
2 parents 0288cc9 + 1901a7e commit 20bd940
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 34 deletions.
50 changes: 26 additions & 24 deletions 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
Expand All @@ -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'),
Expand All @@ -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')),
Expand Down
2 changes: 1 addition & 1 deletion apps/devmo/urls.py
Expand Up @@ -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"),
Expand Down
10 changes: 5 additions & 5 deletions 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
Expand All @@ -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'
Expand Down Expand Up @@ -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)
9 changes: 5 additions & 4 deletions urls.py
Expand Up @@ -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')),
Expand All @@ -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')),
Expand Down Expand Up @@ -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."""
Expand Down

0 comments on commit 20bd940

Please sign in to comment.