Commit bfb81152 authored by Florent Chehab's avatar Florent Chehab
Browse files

Closes #63

Should fix bug regarding lack of static files
parent 7266140c
Pipeline #35519 passed with stages
in 3 minutes and 39 seconds
...@@ -52,7 +52,7 @@ test_back: ...@@ -52,7 +52,7 @@ test_back:
- postgres:10.5 - postgres:10.5
script: script:
- cd backend - cd backend
- pytest base_app/ frontend_app/ backend_app/ --cov-report html - pytest base_app/ backend_app/ --cov-report html
artifacts: artifacts:
paths: paths:
- backend/htmlcov/ - backend/htmlcov/
......
...@@ -13,7 +13,7 @@ reformat_backend: ...@@ -13,7 +13,7 @@ reformat_backend:
docker-compose exec backend sh -c "cd backend && black ." docker-compose exec backend sh -c "cd backend && black ."
test_backend: test_backend:
docker-compose exec backend sh -c "cd backend && pytest base_app/ frontend_app/ backend_app/" docker-compose exec backend sh -c "cd backend && pytest base_app/ backend_app/"
check_backend: check_backend:
docker-compose exec backend sh -c "cd backend && ./manage.py check" docker-compose exec backend sh -c "cd backend && ./manage.py check"
......
...@@ -13,6 +13,7 @@ from os.path import dirname ...@@ -13,6 +13,7 @@ from os.path import dirname
import sys import sys
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
# Is the root of the REPOSITORY
BASE_DIR = dirname(dirname(dirname(os.path.abspath(__file__)))) BASE_DIR = dirname(dirname(dirname(os.path.abspath(__file__))))
SECRET_KEY = os.environ["SECRET_KEY"] SECRET_KEY = os.environ["SECRET_KEY"]
...@@ -31,7 +32,7 @@ INSTALLED_APPS = [ ...@@ -31,7 +32,7 @@ INSTALLED_APPS = [
"rest_framework", "rest_framework",
"rest_framework.authtoken", "rest_framework.authtoken",
"backend_app", "backend_app",
"frontend_app", "base_app",
"webpack_loader", "webpack_loader",
] ]
...@@ -61,14 +62,14 @@ else: ...@@ -61,14 +62,14 @@ else:
# Webpack loader related # Webpack loader related
WEBPACK_LOADER = { WEBPACK_LOADER = {
"DEFAULT": { "DEFAULT": {
"BUNDLE_DIR_NAME": "frontend_app/bundles/", "BUNDLE_DIR_NAME": "base_app/bundles/",
"STATS_FILE": os.path.join(BASE_DIR, "frontend/webpack-stats.json"), "STATS_FILE": os.path.join(BASE_DIR, "frontend/webpack-stats.json"),
} }
} }
STATICFILES_DIRS = ( STATICFILES_DIRS = (
os.path.join( os.path.join(
BASE_DIR, "backend/static/frontend_app/bundles/" BASE_DIR, "backend/base_app/static/base_app"
), # We do this so that django's collectstatic copies or our bundles to the STATIC_ROOT or syncs them to whatever storage we use. ), # We do this so that django's collectstatic copies or our bundles to the STATIC_ROOT or syncs them to whatever storage we use.
) )
# End of webpack loader related # End of webpack loader related
......
...@@ -18,13 +18,8 @@ ...@@ -18,13 +18,8 @@
</body> </body>
{% load static %} {% load static %}
<!-- <script src="{% static '/frontend_app/react-dist/react.production.min.js' %}"></script> --> <link rel="stylesheet" href="{% static '/base_app/leaflet-dist/leaflet.css' %}"/>
<link rel="stylesheet" href="{% static '/frontend_app/leaflet-dist/leaflet.css' %}"/> <link rel="stylesheet" href="{% static '/base_app/custom_leaflet.css' %}"/>
<link rel="stylesheet" href="{% static '/frontend_app/custom_leaflet.css' %}"/>
<!-- <link rel="stylesheet" href="{% static '/frontend_app/main.css' %}"/> -->
<!-- <script src="{% static '/frontend_app/leaflet-dist/leaflet.js' %}"></script> -->
<!-- <script src="{% static '/frontend_app/react-leaflet-dist/react-leaflet.js' %}"></script> -->
<!-- <script src="{% static '/frontend_app/main.js' %}"></script> -->
{% render_bundle 'main' %} {% render_bundle 'main' %}
{% render_bundle 'vendor' %} {% render_bundle 'vendor' %}
......
from django.conf import settings from django.conf import settings
from django.conf.urls.static import static
from django.conf.urls import include, url from django.conf.urls import include, url
from django.conf.urls.static import static
from django.contrib import admin from django.contrib import admin
from django.views.generic.base import RedirectView from django.views.generic.base import RedirectView
import django_cas_ng.views import django_cas_ng.views
from . import views from . import views
if settings.DEBUG: if settings.DEBUG:
...@@ -26,7 +28,7 @@ urlpatterns += [ ...@@ -26,7 +28,7 @@ urlpatterns += [
django_cas_ng.views.CallbackView.as_view(), django_cas_ng.views.CallbackView.as_view(),
name="cas_ng_proxy_callback", name="cas_ng_proxy_callback",
), ),
url(r"^app/.*", include("frontend_app.urls")), url(r"^app/.*", views.index),
url(r"^$", RedirectView.as_view(url="./app/"), name="go to real home"), url(r"^$", RedirectView.as_view(url="./app/"), name="go to real home"),
url(r"", include("backend_app.urls")), url(r"", include("backend_app.urls")),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
import json
import re
from django.contrib.auth.models import Group from django.contrib.auth.models import Group
from backend_app.utils import is_member
from django.http import HttpResponse from django.http import HttpResponse
import re from django.shortcuts import render
import json
from backend_app.utils import is_member
def role_change(request): def role_change(request):
...@@ -26,3 +29,12 @@ def role_change(request): ...@@ -26,3 +29,12 @@ def role_change(request):
role = "moderator" role = "moderator"
return HttpResponse(json.dumps({"role_actuel": role})) return HttpResponse(json.dumps({"role_actuel": role}))
def index(request):
"""
View to to display the index app that contains the JS / CSS
The "template" displayed is in ./templates/index.html
"""
return render(request, "index.html")
from django.apps import AppConfig
class FrontendConfig(AppConfig):
name = "frontend"
from django.urls import path
from . import views
urlpatterns = [path("", views.index)]
from django.shortcuts import render
def index(request):
return render(request, "frontend_app/index.html")
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