Commit bee7ef35 authored by Florent Chehab's avatar Florent Chehab

Merge branch 'remove_frontend_app_django' into 'master'

Closes #63 [IMPORTANT: also fixes startup crash with fresh install regarding the lack of static files)

Closes #63

See merge request !52
parents 7664c958 bfb81152
Pipeline #35520 passed with stages
in 3 minutes and 47 seconds
......@@ -52,7 +52,7 @@ test_back:
- postgres:10.5
script:
- cd backend
- pytest base_app/ frontend_app/ backend_app/ --cov-report html
- pytest base_app/ backend_app/ --cov-report html
artifacts:
paths:
- backend/htmlcov/
......
......@@ -13,7 +13,7 @@ reformat_backend:
docker-compose exec backend sh -c "cd backend && black ."
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:
docker-compose exec backend sh -c "cd backend && ./manage.py check"
......
......@@ -13,6 +13,7 @@ from os.path import dirname
import sys
# 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__))))
SECRET_KEY = os.environ["SECRET_KEY"]
......@@ -31,7 +32,7 @@ INSTALLED_APPS = [
"rest_framework",
"rest_framework.authtoken",
"backend_app",
"frontend_app",
"base_app",
"webpack_loader",
]
......@@ -61,14 +62,14 @@ else:
# Webpack loader related
WEBPACK_LOADER = {
"DEFAULT": {
"BUNDLE_DIR_NAME": "frontend_app/bundles/",
"BUNDLE_DIR_NAME": "base_app/bundles/",
"STATS_FILE": os.path.join(BASE_DIR, "frontend/webpack-stats.json"),
}
}
STATICFILES_DIRS = (
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.
)
# End of webpack loader related
......
......@@ -18,13 +18,8 @@
</body>
{% load static %}
<!-- <script src="{% static '/frontend_app/react-dist/react.production.min.js' %}"></script> -->
<link rel="stylesheet" href="{% static '/frontend_app/leaflet-dist/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> -->
<link rel="stylesheet" href="{% static '/base_app/leaflet-dist/leaflet.css' %}"/>
<link rel="stylesheet" href="{% static '/base_app/custom_leaflet.css' %}"/>
{% render_bundle 'main' %}
{% render_bundle 'vendor' %}
......
from django.conf import settings
from django.conf.urls.static import static
from django.conf.urls import include, url
from django.conf.urls.static import static
from django.contrib import admin
from django.views.generic.base import RedirectView
import django_cas_ng.views
from . import views
if settings.DEBUG:
......@@ -26,7 +28,7 @@ urlpatterns += [
django_cas_ng.views.CallbackView.as_view(),
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"", include("backend_app.urls")),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
import json
import re
from django.contrib.auth.models import Group
from backend_app.utils import is_member
from django.http import HttpResponse
import re
import json
from django.shortcuts import render
from backend_app.utils import is_member
def role_change(request):
......@@ -26,3 +29,12 @@ def role_change(request):
role = "moderator"
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