From d22c970f09fccdaefaa44ef71170a077c80bdc59 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Mon, 13 Dec 2010 14:35:30 -0600 Subject: Split urls.py up by view prefix This makes things a lot cleaner and easier to read; we were getting quite clunky. It also sets the stage for url inclusion rather than one base urls.py file. Signed-off-by: Dan McGee --- urls.py | 144 ++++++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 81 insertions(+), 63 deletions(-) diff --git a/urls.py b/urls.py index 45dc8065..77bf8c1b 100644 --- a/urls.py +++ b/urls.py @@ -17,79 +17,93 @@ sitemaps = { admin.autodiscover() -urlpatterns = patterns('', - (r'^packages/flaghelp/$', 'packages.views.flaghelp'), - (r'^packages/signoffs/$', 'packages.views.signoffs'), +urlpatterns = patterns('packages.views', + (r'^packages/flaghelp/$', 'flaghelp'), + (r'^packages/signoffs/$', 'signoffs'), (r'^packages/signoff_package/(?P[A-z0-9]+)/(?P[A-z0-9\-+.]+)/$', - 'packages.views.signoff_package'), - (r'^packages/update/$', 'packages.views.update'), + 'signoff_package'), + (r'^packages/update/$', 'update'), # Preference is for the packages/ url below, but search is kept # because other projects link to it - (r'^packages/search/$', 'packages.views.search'), - (r'^packages/search/(?P\d+)/$', 'packages.views.search'), - (r'^packages/differences/$', 'packages.views.arch_differences'), - (r'^packages/$', 'packages.views.search'), - (r'^packages/(?P\d+)/$', 'packages.views.search'), + (r'^packages/search/$', 'search'), + (r'^packages/search/(?P\d+)/$', 'search'), + (r'^packages/$', 'search'), + (r'^packages/(?P\d+)/$', 'search'), + + (r'^packages/differences/$', 'arch_differences'), (r'^packages/(?P[A-z0-9\-+.]+)/$', - 'packages.views.details'), + 'details'), (r'^packages/(?P[A-z0-9\-]+)/(?P[A-z0-9\-+.]+)/$', - 'packages.views.details'), + 'details'), (r'^packages/(?P[A-z0-9\-]+)/(?P[A-z0-9]+)/(?P[A-z0-9\-+.]+)/$', - 'packages.views.details'), + 'details'), (r'^packages/(?P[A-z0-9\-]+)/(?P[A-z0-9]+)/(?P[A-z0-9\-+.]+)/files/$', - 'packages.views.files'), + 'files'), (r'^packages/(?P[A-z0-9\-]+)/(?P[A-z0-9]+)/(?P[A-z0-9\-+.]+)/maintainer/$', - 'packages.views.getmaintainer'), + 'getmaintainer'), (r'^packages/(?P[A-z0-9\-]+)/(?P[A-z0-9]+)/(?P[A-z0-9\-+.]+)/flag/$', - 'packages.views.flag'), + 'flag'), (r'^packages/(?P[A-z0-9\-]+)/(?P[A-z0-9]+)/(?P[A-z0-9\-+.]+)/unflag/$', - 'packages.views.unflag'), + 'unflag'), (r'^packages/(?P[A-z0-9\-]+)/(?P[A-z0-9]+)/(?P[A-z0-9\-+.]+)/download/$', - 'packages.views.download'), + 'download'), - (r'^groups/$', 'packages.views.groups'), + (r'^groups/$', 'groups'), (r'^groups/(?P[A-z0-9]+)/(?P[A-z0-9\-+.]+)/$', - 'packages.views.group_details'), + 'group_details'), + + (r'^opensearch/packages/$', 'opensearch', {}, 'opensearch-packages'), +) - (r'^todo/(\d+)/$', 'todolists.views.view'), - (r'^todo/add/$', 'todolists.views.add'), - (r'^todo/edit/(?P\d+)/$', 'todolists.views.edit'), - (r'^todo/flag/(\d+)/(\d+)/$', 'todolists.views.flag'), +urlpatterns += patterns('todolists.views', + (r'^todo/$', 'list'), + (r'^todo/(\d+)/$', 'view'), + (r'^todo/add/$', 'add'), + (r'^todo/edit/(?P\d+)/$', 'edit'), + (r'^todo/flag/(\d+)/(\d+)/$', 'flag'), (r'^todo/delete/(?P\d+)/$', - 'todolists.views.delete_todolist'), - (r'^todo/$', 'todolists.views.list'), - (r'^todolists/$', 'todolists.views.public_list'), + 'delete_todolist'), + + (r'^todolists/$', 'public_list'), +) - (r'^news/add/$', 'news.views.add'), - (r'^news/preview/$', 'news.views.preview'), +urlpatterns += patterns('news.views', + (r'^news/add/$', 'add'), + (r'^news/preview/$', 'preview'), # old news URLs, permanent redirect view so we don't break all links - (r'^news/(?P\d+)/$', 'news.views.view_redirect'), - (r'^news/(?P[-\w]+)/$', 'news.views.view'), - (r'^news/(?P[-\w]+)/edit/$', 'news.views.edit'), - (r'^news/(?P[-\w]+)/delete/$', 'news.views.delete'), - (r'^news/$', 'news.views.news_list', {}, 'news-list'), - - (r'^mirrors/$', 'mirrors.views.mirrors', {}, 'mirrors-list'), - (r'^mirrors/status/$', 'mirrors.views.status', {}, 'mirror-status'), - (r'^mirrors/status/json/$', 'mirrors.views.status_json', {}, 'mirror-status-json'), - (r'^mirrors/(?P[\.\-\w]+)/$', 'mirrors.views.mirror_details'), - - (r'^mirrorlist/$', 'mirrors.views.generate_mirrorlist', {}, 'mirrorlist'), - (r'^mirrorlist/all/$', 'mirrors.views.find_mirrors', {'countries': ['all']}), - (r'^mirrorlist/all/ftp/$', 'mirrors.views.find_mirrors', + (r'^news/(?P\d+)/$', 'view_redirect'), + (r'^news/(?P[-\w]+)/$', 'view'), + (r'^news/(?P[-\w]+)/edit/$', 'edit'), + (r'^news/(?P[-\w]+)/delete/$', 'delete'), + (r'^news/$', 'news_list', {}, 'news-list'), +) + +urlpatterns += patterns('mirrors.views', + (r'^mirrors/$', 'mirrors', {}, 'mirrors-list'), + (r'^mirrors/(?P[\.\-\w]+)/$', 'mirror_details'), + + (r'^mirrors/status/$', 'status', {}, 'mirror-status'), + (r'^mirrors/status/json/$', 'status_json', {}, 'mirror-status-json'), + + (r'^mirrorlist/$', 'generate_mirrorlist', {}, 'mirrorlist'), + (r'^mirrorlist/all/$', 'find_mirrors', {'countries': ['all']}), + (r'^mirrorlist/all/ftp/$', 'find_mirrors', {'countries': ['all'], 'protocols': ['ftp']}), - (r'^mirrorlist/all/http/$', 'mirrors.views.find_mirrors', + (r'^mirrorlist/all/http/$', 'find_mirrors', {'countries': ['all'], 'protocols': ['http']}), +) - (r'^devel/$', 'devel.views.index'), - (r'^devel/notify/$', 'devel.views.change_notify'), - (r'^devel/profile/$', 'devel.views.change_profile'), - - (r'^devel/newuser/$', 'devel.views.new_user_form'), +urlpatterns += patterns('devel.views', + (r'^devel/$', 'index'), + (r'^devel/notify/$', 'change_notify'), + (r'^devel/profile/$', 'change_profile'), + (r'^devel/newuser/$', 'new_user_form'), +) # Feeds and sitemaps +urlpatterns += patterns('', (r'^feeds/$', 'public.views.feeds', {}, 'feeds-list'), (r'^feeds/news/$', NewsFeed()), (r'^feeds/packages/$', PackageFeed()), @@ -101,31 +115,35 @@ urlpatterns = patterns('', {'sitemaps': sitemaps}), (r'^sitemap-(?P
.+)\.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}), +) # Authentication / Admin - (r'^login/$', 'django.contrib.auth.views.login', { +urlpatterns += patterns('django.contrib.auth.views', + (r'^login/$', 'login', { 'template_name': 'registration/login.html'}), - (r'^accounts/login/$', 'django.contrib.auth.views.login', { + (r'^accounts/login/$', 'login', { 'template_name': 'registration/login.html'}), - (r'^logout/$', 'django.contrib.auth.views.logout', { + (r'^logout/$', 'logout', { 'template_name': 'registration/logout.html'}), - (r'^accounts/logout/$', 'django.contrib.auth.views.logout', { + (r'^accounts/logout/$', 'logout', { 'template_name': 'registration/logout.html'}), - (r'^admin/', include(admin.site.urls)), +) # (mostly) Static Pages - (r'^$', 'public.views.index', {}, 'index'), +urlpatterns += patterns('public.views', + (r'^$', 'index', {}, 'index'), (r'^about/$', direct_to_template, {'template': 'public/about.html'}, 'page-about'), (r'^art/$', direct_to_template, {'template': 'public/art.html'}, 'page-art'), (r'^svn/$', direct_to_template, {'template': 'public/svn.html'}, 'page-svn'), - (r'^developers/$', 'public.views.userlist', { 'type':'Developers' }, 'page-devs'), - (r'^trustedusers/$', 'public.views.userlist', { 'type':'Trusted Users' }, 'page-tus'), - (r'^fellows/$', 'public.views.userlist', { 'type':'Fellows' }, 'page-fellows'), - (r'^donate/$', 'public.views.donate', {}, 'page-donate'), - (r'^download/$', 'public.views.download', {}, 'page-download'), - (r'^opensearch/packages/$', 'packages.views.opensearch', {}, 'opensearch-packages'), - -# Some django internals we use + (r'^developers/$', 'userlist', { 'type':'Developers' }, 'page-devs'), + (r'^trustedusers/$', 'userlist', { 'type':'Trusted Users' }, 'page-tus'), + (r'^fellows/$', 'userlist', { 'type':'Fellows' }, 'page-fellows'), + (r'^donate/$', 'donate', {}, 'page-donate'), + (r'^download/$', 'download', {}, 'page-download'), +) + +urlpatterns += patterns('', + (r'^admin/', include(admin.site.urls)), (r'^jsi18n/$', 'django.views.i18n.null_javascript_catalog'), ) -- cgit v1.2.3-2-g168b