Move development URLs into dev_urls.py.

This commit is contained in:
Vishnu Ks 2016-06-25 07:14:32 +05:30 committed by Tim Abbott
parent 28b6f1d850
commit eb9798027c
2 changed files with 20 additions and 14 deletions

18
zproject/dev_urls.py Normal file
View File

@ -0,0 +1,18 @@
from django.conf.urls import url
from django.conf import settings
import os.path
# These URLs are available only in the development environment
use_prod_static = getattr(settings, 'PIPELINE', False)
static_root = os.path.join(settings.DEPLOY_ROOT, 'prod-static/serve' if use_prod_static else 'static')
urls = [url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': static_root})]
# These are used for voyager development. On a real voyager instance,
# these files would be served by nginx.
if settings.LOCAL_UPLOADS_DIR is not None:
urls += [
url(r'^user_avatars/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': os.path.join(settings.LOCAL_UPLOADS_DIR, "avatars")}),
]

View File

@ -5,6 +5,7 @@ from django.views.generic import TemplateView, RedirectView
from django.utils.module_loading import import_string from django.utils.module_loading import import_string
import os.path import os.path
import zerver.forms import zerver.forms
from zproject import dev_urls
from zproject.legacy_urls import legacy_urls from zproject.legacy_urls import legacy_urls
# NB: There are several other pieces of code which route requests by URL: # NB: There are several other pieces of code which route requests by URL:
@ -289,20 +290,7 @@ urls += [
] ]
if settings.DEVELOPMENT: if settings.DEVELOPMENT:
use_prod_static = getattr(settings, 'PIPELINE', False) urls += dev_urls.urls
static_root = os.path.join(settings.DEPLOY_ROOT,
'prod-static/serve' if use_prod_static else 'static')
urls += [url(r'^static/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': static_root})]
# These are used for voyager development. On a real voyager instance,
# these files would be served by nginx.
if settings.DEVELOPMENT and settings.LOCAL_UPLOADS_DIR is not None:
urls += [
url(r'^user_avatars/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': os.path.join(settings.LOCAL_UPLOADS_DIR, "avatars")}),
]
# The sequence is important; if i18n urls don't come first then # The sequence is important; if i18n urls don't come first then
# reverse url mapping points to i18n urls which causes the frontend # reverse url mapping points to i18n urls which causes the frontend