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.
This commit is contained in:
jo 2022-03-01 13:19:59 +01:00 committed by Kyle Robbertze
parent 4da8d8c06b
commit 9af717ef7f
2 changed files with 8 additions and 9 deletions

View File

@ -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"

View File

@ -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..."