From 9af717ef7ffcc8cd59dd8aaa0ff451e68fa9e7c6 Mon Sep 17 00:00:00 2001 From: jo Date: Tue, 1 Mar 2022 13:19:59 +0100 Subject: [PATCH] feat(api): remove admin app and static files - remove django admin app, - disable static files for production deployment, - keep the rest framework browsable api in dev mode. --- api/libretime_api/settings.py | 16 ++++++++-------- install | 1 - 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/api/libretime_api/settings.py b/api/libretime_api/settings.py index 1eba09b3f..89acea7cf 100644 --- a/api/libretime_api/settings.py +++ b/api/libretime_api/settings.py @@ -32,7 +32,6 @@ ALLOWED_HOSTS = ["*"] INSTALLED_APPS = [ "libretime_api.apps.LibreTimeAPIConfig", - "django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", @@ -107,7 +106,15 @@ AUTH_PASSWORD_VALIDATORS = [ }, ] +# Rest Framework settings +# https://www.django-rest-framework.org/api-guide/settings/ + +renderer_classes = ["rest_framework.renderers.JSONRenderer"] +if DEBUG: + renderer_classes += ["rest_framework.renderers.BrowsableAPIRenderer"] + REST_FRAMEWORK = { + "DEFAULT_RENDERER_CLASSES": renderer_classes, "DEFAULT_AUTHENTICATION_CLASSES": ( "rest_framework.authentication.SessionAuthentication", "rest_framework.authentication.BasicAuthentication", @@ -137,13 +144,6 @@ USE_L10N = True USE_TZ = True -# Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/3.0/howto/static-files/ - -STATIC_URL = "/api/static/" -if not DEBUG: - STATIC_ROOT = LIBRETIME_STATIC_ROOT - AUTH_USER_MODEL = "libretime_api.User" TEST_RUNNER = "libretime_api.tests.runners.ManagedModelTestRunner" diff --git a/install b/install index a5fceb23c..f3decc1d6 100755 --- a/install +++ b/install @@ -1083,7 +1083,6 @@ mkdir -p /etc/airtime sed -e "s@WEB_USER@${web_user}@g" \ -e "s@WEB_ROOT@${web_root}@g" \ "${AIRTIMEROOT}/installer/uwsgi/libretime-api.ini" > /etc/airtime/libretime-api.ini -loudCmd "libretime-api collectstatic --clear --noinput" verbose "...Done" verbose "\n * Setting permissions on /var/log/airtime..."