mirror of https://github.com/zulip/zulip.git
dev_urls: Serve static files with staticfiles_urlpatterns.
The test_docs change is because Django runs test cases with DEBUG = False, which ordinarily means it doesn’t serve /static during tests. Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
parent
239aefca74
commit
afa251de5d
|
@ -403,6 +403,7 @@ def write_instrumentation_reports(full_suite: bool, include_webhooks: bool) -> N
|
||||||
'node-coverage/(?P<path>.*)',
|
'node-coverage/(?P<path>.*)',
|
||||||
'docs/(?P<path>.*)',
|
'docs/(?P<path>.*)',
|
||||||
'casper/(?P<path>.*)',
|
'casper/(?P<path>.*)',
|
||||||
|
'static/(?P<path>.*)',
|
||||||
] + [webhook.url for webhook in WEBHOOK_INTEGRATIONS if not include_webhooks])
|
] + [webhook.url for webhook in WEBHOOK_INTEGRATIONS if not include_webhooks])
|
||||||
|
|
||||||
untested_patterns -= exempt_patterns
|
untested_patterns -= exempt_patterns
|
||||||
|
|
|
@ -152,9 +152,6 @@ class DocPageTest(ZulipTestCase):
|
||||||
self.assertEqual(result.status_code, 301)
|
self.assertEqual(result.status_code, 301)
|
||||||
self.assertIn('hello', result['Location'])
|
self.assertIn('hello', result['Location'])
|
||||||
|
|
||||||
result = self.client_get('/static/favicon.ico')
|
|
||||||
self.assertEqual(result.status_code, 200)
|
|
||||||
|
|
||||||
def test_portico_pages_open_graph_metadata(self) -> None:
|
def test_portico_pages_open_graph_metadata(self) -> None:
|
||||||
# Why Zulip
|
# Why Zulip
|
||||||
url = '/why-zulip/'
|
url = '/why-zulip/'
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from django.conf.urls import url
|
from django.conf.urls import url
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
||||||
from django.views.generic import TemplateView
|
from django.views.generic import TemplateView
|
||||||
import os
|
import os
|
||||||
from django.views.static import serve
|
from django.views.static import serve
|
||||||
|
@ -11,12 +12,8 @@ import zerver.views.development.integrations
|
||||||
# These URLs are available only in the development environment
|
# These URLs are available only in the development environment
|
||||||
|
|
||||||
use_prod_static = getattr(settings, 'PIPELINE_ENABLED', False)
|
use_prod_static = getattr(settings, 'PIPELINE_ENABLED', False)
|
||||||
static_root = os.path.join(settings.DEPLOY_ROOT, 'prod-static/serve' if use_prod_static else 'static')
|
|
||||||
|
|
||||||
urls = [
|
urls = [
|
||||||
# Serve static assets via the Django server
|
|
||||||
url(r'^static/(?P<path>.*)$', serve, {'document_root': static_root}),
|
|
||||||
|
|
||||||
# Serve useful development environment resources (docs, coverage reports, etc.)
|
# Serve useful development environment resources (docs, coverage reports, etc.)
|
||||||
url(r'^coverage/(?P<path>.*)$',
|
url(r'^coverage/(?P<path>.*)$',
|
||||||
serve, {'document_root':
|
serve, {'document_root':
|
||||||
|
@ -67,6 +64,14 @@ urls = [
|
||||||
zerver.views.development.integrations.get_fixtures),
|
zerver.views.development.integrations.get_fixtures),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Serve static assets via the Django server
|
||||||
|
if use_prod_static:
|
||||||
|
urls += [
|
||||||
|
url(r'^static/(?P<path>.*)$', serve, {'document_root': settings.STATIC_ROOT}),
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
urls += staticfiles_urlpatterns()
|
||||||
|
|
||||||
i18n_urls = [
|
i18n_urls = [
|
||||||
url(r'^confirmation_key/$', zerver.views.development.registration.confirmation_key),
|
url(r'^confirmation_key/$', zerver.views.development.registration.confirmation_key),
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue