From cc163d27af354052435047046e5107fd281f008c Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Sun, 5 Jul 2020 15:04:24 +0300 Subject: [PATCH] Add settings and configuration to run the etebase app. --- etebase_server/settings.py | 37 ++++++++++++++++++++++++++++++++----- etebase_server/urls.py | 23 +++++++---------------- templates/success.html | 12 ++++++++++++ 3 files changed, 51 insertions(+), 21 deletions(-) create mode 100644 templates/success.html diff --git a/etebase_server/settings.py b/etebase_server/settings.py index 4ec2216..94ca4d2 100644 --- a/etebase_server/settings.py +++ b/etebase_server/settings.py @@ -15,15 +15,17 @@ import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +AUTH_USER_MODEL = 'myauth.User' + # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ -# SECURITY WARNING: keep the secret key used in production secret! -# SECRET_KEY = '' +# Should be set in the site specific settings +# SECRET_KEY = # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = False ALLOWED_HOSTS = [] @@ -37,11 +39,18 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'corsheaders', + 'rest_framework', + 'fullurl', + 'myauth.apps.MyauthConfig', + 'django_etebase.apps.DjangoEtebaseConfig', + 'django_etebase.token_auth.apps.TokenAuthConfig', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', + 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', @@ -54,7 +63,9 @@ ROOT_URLCONF = 'etebase_server.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], + 'DIRS': [ + os.path.join(BASE_DIR, 'templates') + ], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ @@ -76,7 +87,8 @@ WSGI_APPLICATION = 'etebase_server.wsgi.application' DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + 'NAME': os.environ.get('ETEBASE_DB_PATH', + os.path.join(BASE_DIR, 'db.sqlite3')), } } @@ -113,8 +125,23 @@ USE_L10N = True USE_TZ = True +# Cors +CORS_ORIGIN_ALLOW_ALL = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.0/howto/static-files/ +STATIC_ROOT = os.environ.get('DJANGO_STATIC_ROOT', os.path.join(BASE_DIR, 'assets')) STATIC_URL = '/static/' + +MEDIA_ROOT = os.environ.get('DJANGO_MEDIA_ROOT', os.path.join(BASE_DIR, 'media')) +MEDIA_URL = '/user-media/' + +ETEBASE_API_PERMISSIONS = ('rest_framework.permissions.IsAuthenticated', ) +ETEBASE_API_AUTHENTICATORS = ('django_etebase.token_auth.authentication.TokenAuthentication', + 'rest_framework.authentication.SessionAuthentication') + +try: + from etebase_server_settings import * +except ImportError: + pass diff --git a/etebase_server/urls.py b/etebase_server/urls.py index 4ac11e2..0c114af 100644 --- a/etebase_server/urls.py +++ b/etebase_server/urls.py @@ -1,21 +1,12 @@ -"""etebase_server URL Configuration - -The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/3.0/topics/http/urls/ -Examples: -Function views - 1. Add an import: from my_app import views - 2. Add a URL to urlpatterns: path('', views.home, name='home') -Class-based views - 1. Add an import: from other_app.views import Home - 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') -Including another URLconf - 1. Import the include() function: from django.urls import include, path - 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) -""" +from django.conf.urls import include, url from django.contrib import admin from django.urls import path +from django.views.generic import TemplateView urlpatterns = [ - path('admin/', admin.site.urls), + url(r'^api/', include('django_etebase.urls')), + url(r'^admin/', admin.site.urls), + url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), + + path('', TemplateView.as_view(template_name='success.html')), ] diff --git a/templates/success.html b/templates/success.html new file mode 100644 index 0000000..c7cf494 --- /dev/null +++ b/templates/success.html @@ -0,0 +1,12 @@ + + + + It works! + + +

It works!

+

+ Please refer to the README to complete the final steps if you haven't done so already. +

+ +