Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Surlex URL's #34

Merged
merged 3 commits into from

1 participant

This page is out of date. Refresh to see the latest.
Showing with 27 additions and 13 deletions.
  1. +26 −13 newsletter/urls.py
  2. +1 −0  requirements.txt
View
39 newsletter/urls.py
@@ -1,21 +1,34 @@
from django.conf.urls.defaults import *
+from surlex.dj import surl
+
urlpatterns = patterns('newsletter.views',
- # TODO: Use surlex here to simplify regexes
- url(r'^$', 'newsletter_list', name='newsletter_list'),
+ surl('^$', 'newsletter_list', name='newsletter_list'),
- url(r'^(?P<newsletter_slug>[-\w]+)/$','newsletter_detail', name='newsletter_detail'),
+ surl('^<newsletter_slug:s>/$',
+ 'newsletter_detail', name='newsletter_detail'),
- url(r'^(?P<newsletter_slug>[-\w]+)/subscribe/$', 'subscribe_request', name='newsletter_subscribe_request'),
- url(r'^(?P<newsletter_slug>[-\w]+)/subscribe/confirm/$', 'subscribe_request', kwargs={'confirm':True}, name='newsletter_subscribe_confirm'),
- url(r'^(?P<newsletter_slug>[-\w]+)/update/$', 'update_request', name='newsletter_update_request'),
- url(r'^(?P<newsletter_slug>[-\w]+)/unsubscribe/$', 'unsubscribe_request', name='newsletter_unsubscribe_request'),
- url(r'^(?P<newsletter_slug>[-\w]+)/unsubscribe/confirm/$', 'unsubscribe_request', kwargs={'confirm':True}, name='newsletter_unsubscribe_confirm'),
+ surl('^<newsletter_slug:s>/subscribe/$', 'subscribe_request',
+ name='newsletter_subscribe_request'),
+ surl('^<newsletter_slug:s>/subscribe/confirm/$', 'subscribe_request',
+ kwargs={'confirm': True}, name='newsletter_subscribe_confirm'),
+ surl('^<newsletter_slug:s>/update/$', 'update_request',
+ name='newsletter_update_request'),
+ surl('^<newsletter_slug:s>/unsubscribe/$', 'unsubscribe_request',
+ name='newsletter_unsubscribe_request'),
+ surl('^<newsletter_slug:s>/unsubscribe/confirm/$', 'unsubscribe_request',
+ kwargs={'confirm': True}, name='newsletter_unsubscribe_confirm'),
- url(r'^(?P<newsletter_slug>[-\w]+)/subscription/(?P<email>[-_a-zA-Z0-9@\.\+~]+)/(?P<action>[a-z]+)/activate/(?P<activation_code>[a-zA-Z0-9]+)/$', 'update_subscription', name='newsletter_update_activate'),
- url(r'^(?P<newsletter_slug>[-\w]+)/subscription/(?P<email>[-_a-zA-Z0-9@\.\+~]+)/(?P<action>[a-z]+)/activate/$', 'update_subscription', name='newsletter_update'),
+ surl('^<newsletter_slug:s>/subscription/<email=[-_a-zA-Z0-9@\.\+~]+>/'
+ '<action:s>/activate/<activation_code:s>/$',
+ 'update_subscription', name='newsletter_update_activate'),
+ surl('^<newsletter_slug:s>/subscription/<email=[-_a-zA-Z0-9@\.\+~]+>/'
+ '<action:s>/activate/$',
+ 'update_subscription', name='newsletter_update'),
- url(r'^(?P<newsletter_slug>[-\w]+)/archive/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\w{1,2})/(?P<slug>[-\w]+)/$', 'archive_detail', name='newsletter_archive_detail'),
- url(r'^(?P<newsletter_slug>[-\w]+)/archive/$', 'archive', name='newsletter_archive'),
-)
+ surl('^<newsletter_slug:s>/archive/<year:Y>/<month:m>/<day:d>/<slug:s>/$',
+ 'archive_detail', name='newsletter_archive_detail'),
+ surl('^<newsletter_slug:s>/archive/$',
+ 'archive', name='newsletter_archive'),
+)
View
1  requirements.txt
@@ -3,3 +3,4 @@ Django>=1.3
vobject
chardet
PIL
+surlex
Something went wrong with that request. Please try again.