aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKelley Spoon <kelley.spoon@linaro.org>2021-06-16 21:53:25 -0500
committerKelley Spoon <kelley.spoon@linaro.org>2021-06-17 03:01:34 +0000
commit7c2d981bab5697843daa5cbfb68f0e835d11843e (patch)
tree7415d0e8c56130831d09b2494ac89bd650d93db7
parentbbe489e5ca3c1ebd8c3cea27fabb0fa12f39fedc (diff)
downloadlinaro-license-protection-7c2d981bab5697843daa5cbfb68f0e835d11843e.tar.gz
staticfiles: handle staticfiles correctly
Let's use the static() helper in our templates to correctly generate a URL for our static files. We also need to add our STATIC_URL to the urlpatterns list, and straighten out the settings to ensure the static root is found and loaded correctly. Change-Id: I933bcf9c9eeec7300dc0f3935b07179446f7b621 Reviewed-on: https://review.linaro.org/c/infrastructure/linaro-license-protection/+/38933 Reviewed-by: Kelley Spoon <kelley.spoon@linaro.org>
-rw-r--r--settings.py5
-rw-r--r--templates/header.html9
-rw-r--r--urls.py3
3 files changed, 11 insertions, 6 deletions
diff --git a/settings.py b/settings.py
index a859b1b..005c5c8 100644
--- a/settings.py
+++ b/settings.py
@@ -80,7 +80,10 @@ STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
- STATIC_ROOT
+ # Also:
+ # - for some reason, django doesn't like this to be "STATIC_ROOT"
+ # - this must be a tuple, so even if only 1 entry leave a trailing comma
+ os.path.join(PROJECT_ROOT, 'license_protected_downloads/static'),
)
# List of finder classes that know how to find static files in
diff --git a/templates/header.html b/templates/header.html
index 89468a3..3496d7b 100644
--- a/templates/header.html
+++ b/templates/header.html
@@ -1,5 +1,6 @@
<html>
<head>
+ {% load static %}
{% if dl != None %}
<meta http-equiv="REFRESH" content="0;url={{ dl }}">
{% endif %}
@@ -11,11 +12,11 @@
rel="stylesheet" type="text/css" >
<script language="javascript" type="text/javascript"
src="//www.linaro.org/remote/js/linarofamily.js"></script>
- <script type="text/javascript" src="/js/jquery-1.7.2.js"></script>
- <script type="text/javascript" src="/js/jquery-ui-1.8.23.custom.min.js"></script>
+ <script type="text/javascript" src="{% static 'js/jquery-1.7.2.js' %}"></script>
+ <script type="text/javascript" src="{% static 'js/jquery-ui-1.8.23.custom.min.js' %}"></script>
<script type="text/javascript" src="//cdn.datatables.net/1.10.10/js/jquery.dataTables.min.js"></script>
- <link rel="stylesheet" type="text/css" href="/css/jquery-ui/jquery-ui-1.8.23.custom.css">
- <link rel="stylesheet" type="text/css" href="/css/linaro.css">
+ <link rel="stylesheet" type="text/css" href="{% static 'css/jquery-ui/jquery-ui-1.8.23.custom.css' %}">
+ <link rel="stylesheet" type="text/css" href="{% static 'css/linaro.css' %}">
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.10/css/jquery.dataTables.min.css">
<style type="text/css">
div#footer {
diff --git a/urls.py b/urls.py
index c2ad964..de3675b 100644
--- a/urls.py
+++ b/urls.py
@@ -4,6 +4,7 @@ from django.views.generic import RedirectView
from django.conf.urls import include, url
from django.urls import reverse_lazy
from django.views.static import serve
+from django.conf.urls.static import static
from django.contrib.auth import views as auth_views
@@ -125,7 +126,7 @@ urlpatterns = [
publish_views),
url(r'^api/v3/link_latest/(?P<path>.*)$',
link_latest_views),
-]
+] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
if settings.TRACK_DOWNLOAD_STATS:
urlpatterns += [