diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6e34577511a471e548c622e55d2e0402eba54ec4..f0dbff43ff2e215172bca4f184ff6fb43d54be73 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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/ diff --git a/Makefile b/Makefile index c9d4af59119762f22b6a812b9f35a7747656f25f..b6c01e844dd548e92d6e7226088883a5c098151f 100644 --- a/Makefile +++ b/Makefile @@ -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" diff --git a/backend/base_app/settings.py b/backend/base_app/settings.py index a1f1eb8b6ab2c79b9e8f7d6392cd02bbab2e5554..aedbbee210ef1e24bb6f75677bb44f18f5540283 100644 --- a/backend/base_app/settings.py +++ b/backend/base_app/settings.py @@ -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 diff --git a/backend/frontend_app/static/frontend_app b/backend/base_app/static/base_app similarity index 100% rename from backend/frontend_app/static/frontend_app rename to backend/base_app/static/base_app diff --git a/backend/base_app/templates/index.html b/backend/base_app/templates/index.html new file mode 100644 index 0000000000000000000000000000000000000000..11b7f1e95074558c7604ef81e66e9bbb4b1b8900 --- /dev/null +++ b/backend/base_app/templates/index.html @@ -0,0 +1,27 @@ +{% load render_bundle from webpack_loader %} + + + + + + Outgoing REX + + + +
+ +
+ + + {% load static %} + + + + {% render_bundle 'main' %} + {% render_bundle 'vendor' %} + + diff --git a/backend/base_app/urls.py b/backend/base_app/urls.py index 1d0c15c691b4e3c5a5ae0376e26a9c9127fe95e5..bd88f2b3e4eea174bfb33d2ecf8e87ac478f2a27 100644 --- a/backend/base_app/urls.py +++ b/backend/base_app/urls.py @@ -1,9 +1,11 @@ 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) diff --git a/backend/base_app/views.py b/backend/base_app/views.py index d644f8f57a74a2a628ca1e1527f7e92c1888086d..de398120b3a7161d9143fb8ed6d48981d556604e 100644 --- a/backend/base_app/views.py +++ b/backend/base_app/views.py @@ -1,8 +1,11 @@ +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") diff --git a/backend/frontend_app/__init__.py b/backend/frontend_app/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/backend/frontend_app/apps.py b/backend/frontend_app/apps.py deleted file mode 100644 index 5dad3666afd8011c5e24f7750cd0a85b01d67957..0000000000000000000000000000000000000000 --- a/backend/frontend_app/apps.py +++ /dev/null @@ -1,5 +0,0 @@ -from django.apps import AppConfig - - -class FrontendConfig(AppConfig): - name = "frontend" diff --git a/backend/frontend_app/templates/frontend_app/index.html b/backend/frontend_app/templates/frontend_app/index.html deleted file mode 100644 index ccf9a670711d1a674a737b3e220d9aa24e5ddd13..0000000000000000000000000000000000000000 --- a/backend/frontend_app/templates/frontend_app/index.html +++ /dev/null @@ -1,32 +0,0 @@ -{% load render_bundle from webpack_loader %} - - - - - - Outgoing REX - - - -
- -
- - - {% load static %} - - - - - - - - - {% render_bundle 'main' %} - {% render_bundle 'vendor' %} - - diff --git a/backend/frontend_app/urls.py b/backend/frontend_app/urls.py deleted file mode 100644 index bb9c5f83abd785776fd8930325607b1f7d120cb6..0000000000000000000000000000000000000000 --- a/backend/frontend_app/urls.py +++ /dev/null @@ -1,5 +0,0 @@ -from django.urls import path -from . import views - - -urlpatterns = [path("", views.index)] diff --git a/backend/frontend_app/views.py b/backend/frontend_app/views.py deleted file mode 100644 index cb10e3625b515a1536105a23fd19954a1ee9938e..0000000000000000000000000000000000000000 --- a/backend/frontend_app/views.py +++ /dev/null @@ -1,5 +0,0 @@ -from django.shortcuts import render - - -def index(request): - return render(request, "frontend_app/index.html")