addons-server/mkt/urls.py

124 строки
3.9 KiB
Python
Исходник Обычный вид История

from django.conf import settings
from django.conf.urls.defaults import patterns, url, include
from django.contrib import admin
from django.shortcuts import redirect
from django.views.decorators.cache import cache_page
from django.views.i18n import javascript_catalog
2012-02-04 04:56:25 +04:00
from apps.users.views import logout
from apps.users.urls import (detail_patterns as user_detail_patterns,
users_patterns as users_users_patterns)
from mkt.account.urls import (purchases_patterns, settings_patterns,
users_patterns as mkt_users_patterns)
from mkt.developers.views import login
2012-04-17 04:09:46 +04:00
from mkt.zadmin.views import featured_apps_admin
2012-02-04 04:56:25 +04:00
admin.autodiscover()
handler404 = 'mkt.site.views.handler404'
handler500 = 'mkt.site.views.handler500'
APP_SLUG = r"""(?P<app_slug>[^/<>"']+)"""
urlpatterns = patterns('',
# Home.
2012-04-11 12:29:56 +04:00
url('^$', 'mkt.home.views.home', name='home'),
2012-04-06 02:48:54 +04:00
2012-03-17 01:16:07 +04:00
# App Detail pages.
('^app/%s/' % APP_SLUG, include('mkt.detail.urls')),
# Browse pages.
('^apps/', include('mkt.browse.urls')),
# Replace the "old" Developer Hub with the "new" Marketplace one.
('^developers/', include('mkt.developers.urls')),
# Submission.
('^developers/submit/app/', include('mkt.submit.urls')),
2012-04-25 04:15:49 +04:00
# Dev Ecosystem
('^ecosystem/', include('mkt.ecosystem.urls')),
2012-03-21 00:20:58 +04:00
# In-app payments.
2012-03-28 00:31:00 +04:00
('^inapp-pay/', include('mkt.inapp_pay.urls')),
2012-03-21 00:20:58 +04:00
2012-03-28 12:25:01 +04:00
# Site events data.
url('^statistics/events-(?P<start>\d{8})-(?P<end>\d{8}).json$',
'stats.views.site_events', name='amo.site_events'),
# Site statistics that we are going to catch, the rest will fall through.
url('^statistics/', include('stats.urls')),
# Fall through for any URLs not matched above stats dashboard.
url('^statistics/', lambda r: redirect('/'), name='statistics.dashboard'),
# Support (e.g., refunds, FAQs).
('^support/', include('mkt.support.urls')),
# Users (Legacy).
('^user/(?P<user_id>\d+)/', include(user_detail_patterns)),
('^users/', include(users_users_patterns)),
# Account info (e.g., purchases, settings).
('^users/', include(mkt_users_patterns)),
('^purchases/', include(purchases_patterns)),
('^settings', include(settings_patterns)),
2012-02-09 15:27:26 +04:00
# Site Search.
('^search/', include('mkt.search.urls')),
2012-04-03 01:34:59 +04:00
# Reviewer tools.
('^reviewers/', include('mkt.reviewers.urls')),
2012-04-03 01:34:59 +04:00
# Editor tools.
('^editors/', include('editors.urls')),
# Javascript translations.
url('^jsi18n.js$', cache_page(60 * 60 * 24 * 365)(javascript_catalog),
{'domain': 'javascript', 'packages': ['zamboni']}, name='jsi18n'),
# Paypal, needed for IPNs only.
('^services/', include('paypal.urls')),
2012-04-17 04:09:46 +04:00
# Featured apps selector.
url('^admin/apps/featured$', featured_apps_admin,
name='admin.featured_apps'),
# AMO admin (not django admin).
('^admin/', include('zadmin.urls')),
2012-02-24 01:31:57 +04:00
# Accept extra junk at the end for a cache-busting build id.
url('^addons/buttons.js(?:/.+)?$', 'addons.buttons.js'),
2012-02-09 15:27:26 +04:00
# Developer Registration Login.
url('^login$', login, name='users.login'),
url('^logout$', logout, name='users.logout'),
# Try and keep urls without a prefix at the bottom of the list for
# minor performance reasons.
# Misc pages.
('', include('mkt.site.urls')),
# Services.
('', include('apps.amo.urls')),
)
if settings.TEMPLATE_DEBUG:
# Remove leading and trailing slashes so the regex matches.
media_url = settings.MEDIA_URL.lstrip('/').rstrip('/')
urlpatterns += patterns('',
(r'^%s/(?P<path>.*)$' % media_url, 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),
)
if settings.SERVE_TMP_PATH and settings.DEBUG:
# Serves any URL like /tmp/* from your local ./tmp/ dir
urlpatterns += patterns('',
(r'^tmp/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.TMP_PATH}),
)