Commit 27f98bdd authored by Claude Paroz's avatar Claude Paroz

Modernized urls.py syntax

parent 6c1b8e45
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.conf.urls import include, patterns, url from django.conf.urls import include, url
from django.conf import settings from django.conf import settings
from django.contrib import admin from django.contrib import admin
from django.contrib.auth import views as auth_views
from django.views.generic import TemplateView from django.views.generic import TemplateView
from django.views.static import serve
admin.autodiscover() from common import views as common_views
from stats import views as stats_views
urlpatterns = patterns('',
url( urlpatterns = [
regex = r'^$', url(r'^$',
view = 'common.views.index', common_views.index,
name = 'home'), name='home'),
url( url(r'^about/$',
regex = r'^about/$', common_views.about,
view = 'common.views.about', name='about'),
name = 'about'), url(r'^login/$',
url( common_views.site_login,
regex = r'^login/$', name='login'),
view = 'common.views.site_login', url(r'^register/$',
name = 'login'), common_views.site_register,
url( name='register'),
regex = r'^register/$', url(r'^help/(?P<topic>\w+)/$',
view = 'common.views.site_register', common_views.help,
name = 'register'), name='help'),
url( url(r'^register/success$',
regex = r'^help/(?P<topic>\w+)/$', TemplateView.as_view(template_name="registration/register_success.html"),
view = 'common.views.help', name='register_success'),
name = 'help'), url(r'^register/activate/(?P<key>\w+)$',
url( common_views.activate_account,
regex = r'^register/success$', name='register_activation'),
view = TemplateView.as_view(template_name="registration/register_success.html"), url(r'^password_reset/$',
name = 'register_success'), auth_views.password_reset,
url( kwargs={'template_name':'registration/password_reset_form.html'},
regex = r'^register/activate/(?P<key>\w+)$',
view = 'common.views.activate_account',
name = 'register_activation'),
url(
regex = r'^password_reset/$',
view = 'django.contrib.auth.views.password_reset',
kwargs = {'template_name':'registration/password_reset_form.html'},
name='password_reset'), name='password_reset'),
url( url(r'^password_reset/done/$',
regex = r'^password_reset/done/$', auth_views.password_reset_done,
view = 'django.contrib.auth.views.password_reset_done', kwargs={'template_name':'registration/password_reset_done.html'},
kwargs = {'template_name':'registration/password_reset_done.html'},
name='password_reset_done'), name='password_reset_done'),
url( url(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
regex = r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', auth_views.password_reset_confirm,
view = 'django.contrib.auth.views.password_reset_confirm',
name='password_reset_confirm'), name='password_reset_confirm'),
url( url(r'^reset/done/$',
regex = r'^reset/done/$', auth_views.password_reset_complete,
view = 'django.contrib.auth.views.password_reset_complete',
name='password_reset_complete'), name='password_reset_complete'),
url(r'^teams/', include('teams.urls')), url(r'^teams/', include('teams.urls')),
url(r'^people/', include('people.urls')), url(r'^people/', include('people.urls')),
url(# users is the hardcoded url in the contrib.auth User class, making it identical to /people url(# users is the hardcoded url in the contrib.auth User class, making it identical to /people
...@@ -62,62 +56,50 @@ urlpatterns = patterns('', ...@@ -62,62 +56,50 @@ urlpatterns = patterns('',
url(r'^i18n/', include('django.conf.urls.i18n')), url(r'^i18n/', include('django.conf.urls.i18n')),
url(r'^admin/', include(admin.site.urls)), url(r'^admin/', include(admin.site.urls)),
url(r'^rss/', include('feeds.urls')), url(r'^rss/', include('feeds.urls')),
) ]
urlpatterns += patterns('stats.views', urlpatterns += [
url( url(r'^module/(?P<format>(html|json|xml))?/?$',
regex = r'^module/(?P<format>(html|json|xml))?/?$', stats_views.modules,
view = 'modules', name='modules'),
name = 'modules'), url(r'^module/po/(?P<module_name>[\w\-\+]+)/(?P<domain>[\w~\-]+)/(?P<branch_name>[\w\-\.]+)/(?P<filename>.*)$',
url( stats_views.dynamic_po,
regex = r'^module/po/(?P<module_name>[\w\-\+]+)/(?P<domain>[\w~\-]+)/(?P<branch_name>[\w\-\.]+)/(?P<filename>.*)$', name='dynamic_po'),
view = 'dynamic_po', url(r'^module/(?P<module_name>[\w\-\+]+)/$',
name = 'dynamic_po'), stats_views.module,
url( name='module'),
regex = r'^module/(?P<module_name>[\w\-\+]+)/$', url(r'^module/(?P<module_name>[\w\-\+]+)/edit/branches/$',
view = 'module', stats_views.module_edit_branches,
name = 'module'), name='module_edit_branches'),
url( url(r'^module/(?P<module_name>[\w\-\+]+)/branch/(?P<branch_name>[\w\-\.]+)/$',
regex = r'^module/(?P<module_name>[\w\-\+]+)/edit/branches/$', stats_views.module_branch),
view = 'module_edit_branches', url(r'^branch/(?P<branch_id>\d+)/refresh/$',
name = 'module_edit_branches'), stats_views.branch_refresh,
url( name='branch_refresh'),
regex = r'^module/(?P<module_name>[\w\-\+]+)/branch/(?P<branch_name>[\w\-\.]+)/$', url( r'^module/(?P<module_name>[\w\-\+]+)/(?P<potbase>[\w~-]+)/(?P<branch_name>[\w\-\.]+)/(?P<langcode>[\w@]+)/images/$',
view = 'module_branch'), stats_views.docimages,
url( name='docimages'),
regex = r'^branch/(?P<branch_id>\d+)/refresh/$', url(r'^releases/(?P<format>(html|json|xml))?/?$',
view = 'branch_refresh', stats_views.releases,
name = 'branch_refresh'),
url(
regex = r'^module/(?P<module_name>[\w\-\+]+)/(?P<potbase>[\w~-]+)/(?P<branch_name>[\w\-\.]+)/(?P<langcode>[\w@]+)/images/$',
view = 'docimages',
name = 'docimages'),
url(
regex = r'^releases/(?P<format>(html|json|xml))?/?$',
view = 'releases',
name = 'releases'), name = 'releases'),
url( url(r'^releases/(?P<release_name>[\w-]+)/(?P<format>(html|xml))?/?$',
regex = r'^releases/(?P<release_name>[\w-]+)/(?P<format>(html|xml))?/?$', stats_views.release,
view = 'release',
name = 'release'), name = 'release'),
url( url(r'^releases/compare/(?P<dtype>\w+)/(?P<rels_to_compare>[/\w-]+)/$',
regex = r'^releases/compare/(?P<dtype>\w+)/(?P<rels_to_compare>[/\w-]+)/$', stats_views.compare_by_releases),
view = 'compare_by_releases'), ]
)
if 'django_openid_auth' in settings.INSTALLED_APPS: if 'django_openid_auth' in settings.INSTALLED_APPS:
urlpatterns += patterns('', urlpatterns += [
(r'^openid/', include('django_openid_auth.urls')), (r'^openid/', include('django_openid_auth.urls')),
) ]
if settings.STATIC_SERVE: if settings.STATIC_SERVE:
urlpatterns += patterns('', urlpatterns += [
url( url(r'^media/(?P<path>.*)$',
regex = r'^media/(?P<path>.*)$', serve,
view = 'django.views.static.serve', kwargs={'document_root': settings.MEDIA_ROOT}),
kwargs = {'document_root': settings.MEDIA_ROOT}), url(r'^POT/(?P<path>.*)$',
url( serve,
regex = r'^POT/(?P<path>.*)$', kwargs={'document_root': settings.POTDIR}),
view = 'django.views.static.serve', ]
kwargs = {'document_root': settings.POTDIR}),
)
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.conf.urls import patterns, url from django.conf.urls import url
from vertimus.feeds import LatestActionsByLanguage, LatestActionsByTeam from vertimus.feeds import LatestActionsByLanguage, LatestActionsByTeam
urlpatterns = patterns('',
urlpatterns = [
url(r'^languages/(?P<locale>.*)/$', LatestActionsByLanguage(), name='lang_feed'), url(r'^languages/(?P<locale>.*)/$', LatestActionsByLanguage(), name='lang_feed'),
url(r'^teams/(?P<team_name>.*)/$', LatestActionsByTeam(), name='team_feed'), url(r'^teams/(?P<team_name>.*)/$', LatestActionsByTeam(), name='team_feed'),
) ]
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.conf.urls import patterns, url from django.conf.urls import url
urlpatterns = patterns('', from languages import views
url( from teams import views as team_views
regex = r'^$',
view = 'languages.views.languages',
name = 'languages'), urlpatterns = [
url( url(r'^$',
regex = r'^(?P<locale>[\w\-@]+)/all/(?P<dtype>(ui|ui-part|doc)+)/$', views.languages,
view = 'languages.views.language_all', name='languages'),
name = 'language_all'), url(r'^(?P<locale>[\w\-@]+)/all/(?P<dtype>(ui|ui-part|doc)+)/$',
url( views.language_all,
regex = r'^(?P<locale>[\w\-@]+)/rel-archives/$', name='language_all'),
view = 'languages.views.release_archives', url(r'^(?P<locale>[\w\-@]+)/rel-archives/$',
name = 'language_release_archives'), views.release_archives,
url( name='language_release_archives'),
regex = r'^(?P<locale>[\w\-@]+)/(?P<release_name>[\w-]+)/(?P<dtype>(ui|ui-part|doc)+)/$', url(r'^(?P<locale>[\w\-@]+)/(?P<release_name>[\w-]+)/(?P<dtype>(ui|ui-part|doc)+)/$',
view = 'languages.views.language_release', views.language_release,
name = 'language_release'), name='language_release'),
url( url(r'^(?P<locale>[\w\-@]+)/(?P<release_name>[\w-]+).xml$',
regex = r'^(?P<locale>[\w\-@]+)/(?P<release_name>[\w-]+).xml$', views.language_release_xml),
view = 'languages.views.language_release_xml'), url(r'^(?P<locale>[\w\-@]+)/(?P<release_name>[\w-]+)/(?P<dtype>(ui|ui-part|doc)+).tar.gz$',
url( views.language_release_tar,
regex = r'^(?P<locale>[\w\-@]+)/(?P<release_name>[\w-]+)/(?P<dtype>(ui|ui-part|doc)+).tar.gz$', name='language_release_tar'),
view = 'languages.views.language_release_tar', url(r'^(?P<team_slug>[\w\-@]+)/$',
name = 'language_release_tar'), team_views.team),
url( ]
regex = r'^(?P<team_slug>[\w\-@]+)/$',
view = 'teams.views.team'),
)
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.conf.urls import patterns, url from django.conf.urls import url
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from people import views from people import views
# Regex order is really important here # Regex order is really important here
urlpatterns = patterns('people.views', urlpatterns = [
url( url(r'^detail_change/$',
r'^detail_change/$',
login_required(views.PersonEditView.as_view()), login_required(views.PersonEditView.as_view()),
name = 'person_detail_change'), name='person_detail_change'),
url( url(r'^password_change/$',
regex = r'^password_change/$', views.person_password_change,
view = 'person_password_change',
name='person_password_change'), name='person_password_change'),
url( url(r'^team_join/$',
regex = r'^team_join/$', views.person_team_join,
view = 'person_team_join',
name='person_team_join'), name='person_team_join'),
url( url(r'^team_leave/(?P<team_slug>[\w\-@]+)/$',
regex = r'^team_leave/(?P<team_slug>[\w\-@]+)/$', views.person_team_leave,
view = 'person_team_leave',
name='person_team_leave'), name='person_team_leave'),
url( url(r'^(?P<pk>\d+)/$',
r'^(?P<pk>\d+)/$',
views.PersonDetailView.as_view(), views.PersonDetailView.as_view(),
name = 'person_detail_id'), name='person_detail_id'),
# Equivalent to the previous, but using username instead of user pk # Equivalent to the previous, but using username instead of user pk
url( url(r'^(?P<slug>[\w@\.\-]+)/$',
r'^(?P<slug>[\w@\.\-]+)/$',
views.PersonDetailView.as_view(), views.PersonDetailView.as_view(),
name = 'person_detail_username'), name='person_detail_username'),
)
urlpatterns += patterns('', url(r'^$',
url(r'^$', views.PeopleListView.as_view(), name='people'), views.PeopleListView.as_view(),
) name='people'),
]
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.conf.urls import patterns, url from django.conf.urls import url
urlpatterns = patterns('teams.views', from teams import views
url(
regex = r'^(?P<format>(xml|json))?/?$',
view = 'teams', urlpatterns = [
name = 'teams'), url(r'^(?P<format>(xml|json))?/?$',
url( views.teams,
regex = r'^(?P<team_slug>[\w\-@]+)/$', name='teams'),
view = 'team', url(r'^(?P<team_slug>[\w\-@]+)/$',
name = 'team_slug'), views.team,
url( name='team_slug'),
regex = r'^(?P<team_slug>[\w\-@]+)/edit/', url(r'^(?P<team_slug>[\w\-@]+)/edit/$',
view = 'team_edit', views.team_edit,
name = 'team_edit'), name='team_edit'),
) ]
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.conf.urls import patterns, url from django.conf.urls import url
urlpatterns = patterns('vertimus.views', from vertimus import views
url(
regex = r'^(?P<stats_id>\d+)/(?P<lang_id>\d+)$',
view = 'vertimus_by_stats_id', urlpatterns = [
name = 'vertimus_by_stats_id'), url(r'^(?P<stats_id>\d+)/(?P<lang_id>\d+)$',
url( views.vertimus_by_stats_id,
regex = r'^(?P<branch_id>\d+)/(?P<domain_id>\d+)/(?P<language_id>\d+)', name='vertimus_by_stats_id'),
view = 'vertimus_by_ids', url(r'^(?P<branch_id>\d+)/(?P<domain_id>\d+)/(?P<language_id>\d+)',
name = 'vertimus_by_ids'), views.vertimus_by_ids,
url( name='vertimus_by_ids'),
regex = r'^diff/(?P<action_id_1>\d+)/(?P<action_id_2>\d+)/(?P<level>\d+)/$', url(r'^diff/(?P<action_id_1>\d+)/(?P<action_id_2>\d+)/(?P<level>\d+)/$',
view = 'vertimus_diff', views.vertimus_diff,
name = 'vertimus_diff'), name='vertimus_diff'),
url( url(r'^uploads/(?P<module_name>[\w\+\-\.]+)/(?P<branch_name>[\w\-\.]+)/(?P<domain_name>[\w~\-]+)/(?P<locale_name>[\w\-@]+)/latest/$',
regex = r'^uploads/(?P<module_name>[\w\+\-\.]+)/(?P<branch_name>[\w\-\.]+)/(?P<domain_name>[\w~\-]+)/(?P<locale_name>[\w\-@]+)/latest/$', views.latest_uploaded_po,
view = 'latest_uploaded_po', name='latest_uploaded_po'),
name = 'latest_uploaded_po'), url('^(?P<module_name>[\w\+\-\.]+)/(?P<branch_name>[\w\-\.]+)/(?P<domain_name>[\w~\-]+)/(?P<locale_name>[\w\-@]+)/level(?P<level>\d+)/$',
url( views.vertimus_by_names,
regex = '^(?P<module_name>[\w\+\-\.]+)/(?P<branch_name>[\w\-\.]+)/(?P<domain_name>[\w~\-]+)/(?P<locale_name>[\w\-@]+)/level(?P<level>\d+)/$', name='vertimus_archives_by_names'),
view = 'vertimus_by_names', url(r'^(?P<module_name>[\w\+\-\.]+)/(?P<branch_name>[\w\-\.]+)/(?P<domain_name>[\w~\-]+)/(?P<locale_name>[\w\-@]+)',
name = 'vertimus_archives_by_names'), views.vertimus_by_names,
url( name='vertimus_by_names'),
regex = r'^(?P<module_name>[\w\+\-\.]+)/(?P<branch_name>[\w\-\.]+)/(?P<domain_name>[\w~\-]+)/(?P<locale_name>[\w\-@]+)', url(r'^(?P<locale>[\w\-@]+)/activity_summary/$',
view = 'vertimus_by_names', views.activity_by_language,
name = 'vertimus_by_names'), name='activity_by_language'),
url( ]
regex = r'^(?P<locale>[\w\-@]+)/activity_summary/$',
view = 'activity_by_language',
name = 'activity_by_language'),
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment