diff options
author | luxagraf <sng@luxagraf.net> | 2018-11-14 13:17:42 -0600 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2018-11-14 13:17:42 -0600 |
commit | a0b95dc2dfb84c682bb8f677e5d471f84e5028fe (patch) | |
tree | 6dd1919856f736c5b644270d59b57e4bb20336c5 /config |
wrote out basic notes skeleton
Diffstat (limited to 'config')
-rw-r--r-- | config/__init__.py | 0 | ||||
-rw-r--r-- | config/base_urls.py | 34 | ||||
-rwxr-xr-x | config/djadmin.sh | 10 | ||||
-rw-r--r-- | config/requirements.txt | 12 | ||||
-rw-r--r-- | config/settings.py | 167 | ||||
-rw-r--r-- | config/wsgi.py | 16 |
6 files changed, 239 insertions, 0 deletions
diff --git a/config/__init__.py b/config/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/config/__init__.py diff --git a/config/base_urls.py b/config/base_urls.py new file mode 100644 index 0000000..bb2fa56 --- /dev/null +++ b/config/base_urls.py @@ -0,0 +1,34 @@ +from django.contrib import admin +from django.urls import path +from django.views.generic.base import RedirectView +from django.conf.urls import include, url +from django.conf.urls.static import static +from django.conf import settings + +from django_registration.backends.activation.views import RegistrationView +from rest_framework import routers + +from pages.views import PageDetailView +from notes.views import NoteViewSet +from accounts.forms import UserForm + +router = routers.DefaultRouter() +router.register(r'notes', NoteViewSet, basename="notes") + +urlpatterns = static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) +urlpatterns += [ + path('admin/', admin.site.urls), + # path(r'profile/', include('accounts.urls')), + path(r'notes/', include('notes.urls')), + path(r'accounts/', include('django_registration.backends.activation.urls')), + path(r'accounts/', include('django.contrib.auth.urls')), + path(r'register/', RegistrationView.as_view(form_class=UserForm), name='django_registration_register',), + path(r'settings/', include('accounts.urls')), + path(r'', include('django_registration.backends.activation.urls')), + path(r'', include('django.contrib.auth.urls')), + path(r'', include('notes.urls')), + path(r'<slug>', PageDetailView.as_view(), name="pages"), + path(r'<path>/<slug>/', PageDetailView.as_view(), name="pages"), + path(r'api/', include(router.urls)), + path(r'api-auth/', include('rest_framework.urls', namespace='rest_framework')) +] diff --git a/config/djadmin.sh b/config/djadmin.sh new file mode 100755 index 0000000..24081d4 --- /dev/null +++ b/config/djadmin.sh @@ -0,0 +1,10 @@ +#!/bin/bash +DIR="$( cd "$( dirname $( dirname "${BASH_SOURCE[0]}" ) )" && pwd )" +PYTHONPATH=$PYTHONPATH:$DIR +PYTHONPATH=$PYTHONPATH:"${DIR}/apps" +PYTHONPATH=$PYTHONPATH:"${DIR}/apps/lib" +PYTHONPATH=$PYTHONPATH:"${DIR}/venv/lib/python3.6/" +export PYTHONPATH +export DJANGO_SETTINGS_MODULE=config.settings +ADMIN="${DIR}/venv/bin/django-admin.py" +$ADMIN $@ diff --git a/config/requirements.txt b/config/requirements.txt new file mode 100644 index 0000000..f174273 --- /dev/null +++ b/config/requirements.txt @@ -0,0 +1,12 @@ +coverage==4.5.1 +Django==2.1.2 +django-extensions==2.1.3 +django-registration==3.0 +django-storages==1.7.1 +django-taggit==0.23.0 +ipython==7.1.1 +ipython-genutils==0.2.0 +mixer==6.1.3 +Pillow==5.3.0 +psycopg2==2.7.5 +pwned-passwords-django==1.3.1 diff --git a/config/settings.py b/config/settings.py new file mode 100644 index 0000000..ade8a84 --- /dev/null +++ b/config/settings.py @@ -0,0 +1,167 @@ +""" +Django settings for project. + +Generated by 'django-admin startproject' using Django 2.1.2. + +For more information on this file, see +https://docs.djangoproject.com/en/2.1/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/2.1/ref/settings/ +""" + +import os +from decouple import config, Csv + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + +SECRET_KEY = config('SECRET_KEY') + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = config('DEBUG', cast=bool) + +AUTH_PROFILE_MODULE = "accounts.UserProfile" +AUTH_USER_MODEL = "accounts.User" + +DEFAULT_FILE_STORAGE = config('DEFAULT_FILE_STORAGE') + +AWS_S3_OBJECT_PARAMETERS = { + 'CacheControl': 'max-age=86400', +} + +ALLOWED_HOSTS = config('ALLOWED_HOSTS', cast=Csv()) + +# Django registration settings +ACCOUNT_ACTIVATION_DAYS = 3 +REGISTRATION_OPEN = True +REGISTRATION_SALT = 'Astra inclinant, sed non obligant' + +# Django Rest Framework +REST_FRAMEWORK = { + 'DEFAULT_PERMISSION_CLASSES': ( + 'rest_framework.permissions.IsAuthenticated', + ) +} + +# APPS +# https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps +DJANGO_APPS = [ + 'django.contrib.admin', + 'django.contrib.sites', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] +THIRD_PARTY_APPS = [ + 'taggit', + 'taggit_serializer', + 'django_extensions', + 'rest_framework', +] +LOCAL_APPS = [ + 'utils', + 'pages', + 'accounts', + 'notes', +] +INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS + + +# https://docs.djangoproject.com/en/dev/ref/settings/#middleware +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'config.base_urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [ + os.path.join(BASE_DIR, 'templates'), + ], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'config.wsgi.application' + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': config('DB_NAME'), + 'USER': config('DB_USER'), + 'PASSWORD': config('DB_PASSWORD'), + 'HOST': config('DB_HOST'), + 'PORT': '', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'pwned_passwords_django.validators.PwnedPasswordsValidator', + 'OPTIONS': { + 'error_message': 'We hate to be the bearers of bad news, but that password is known to be compromised', + 'help_message': 'Your password can\'t be a commonly used password.', + } + }, + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/2.1/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'America/Chicago' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/2.1/howto/static-files/ + +STATIC_URL = '/static/' +STATIC_ROOT = BASE_DIR+'/static/' +MEDIA_URL = '/media/' +MEDIA_ROOT = BASE_DIR+'/media/' + +EMAIL_BACKEND = "django.core.mail.backends.filebased.EmailBackend" +EMAIL_FILE_PATH = os.path.join(BASE_DIR, "sent_emails") diff --git a/config/wsgi.py b/config/wsgi.py new file mode 100644 index 0000000..0c727f0 --- /dev/null +++ b/config/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for myproj project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproj.settings') + +application = get_wsgi_application() |