Skip to content

Commit

Permalink
Merge e14c42c into ebff588
Browse files Browse the repository at this point in the history
  • Loading branch information
salma-nyagaka committed Nov 29, 2018
2 parents ebff588 + e14c42c commit 26376de
Show file tree
Hide file tree
Showing 4 changed files with 179 additions and 3 deletions.
146 changes: 146 additions & 0 deletions authors/settings 2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
"""
Django settings for authors project.
Generated by 'django-admin startproject' using Django 1.11.14.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/ref/settings/
"""

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__)))

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '7pgozr2jn7zs_o%i8id6=rddie!*0f0qy3$oy$(8231i^4*@u3'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []

# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'corsheaders',
'django_extensions',
'rest_framework',
'authors.apps.authentication',
'authors.apps.core',
'authors.apps.profiles',
'rest_framework_swagger',
]

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',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'authors.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'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 = 'authors.wsgi.application'

# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.getenv("DB_NAME", 'authorshaven'),
'HOST': os.getenv("DB_HOST", 'localhost'),
'PASSWORD': os.getenv('DB_PASSWORD', '123'),
'USER': os.getenv('DB_USER', 'postgres'),
'PORT': os.getenv('DB_PORT', '5432')
}
}

# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
'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/1.11/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.10/howto/static-files/

STATIC_URL = '/static/'

CORS_ORIGIN_WHITELIST = (
'0.0.0.0:4000',
'localhost:4000',
)

# Tell Django about the custom `User` model we created. The string
# `authentication.User` tells Django we are referring to the `User` model in
# the `authentication` module. This module is registered above in a setting
# called `INSTALLED_APPS`.
AUTH_USER_MODEL = 'authentication.User'

REST_FRAMEWORK = {
'EXCEPTION_HANDLER': 'authors.apps.core.exceptions.core_exception_handler',
'NON_FIELD_ERRORS_KEY': 'error',

'DEFAULT_AUTHENTICATION_CLASSES': (
# 'authors.apps.authentication.backends.JWTAuthentication',
),
}
3 changes: 1 addition & 2 deletions authors/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',

'corsheaders',
'django_extensions',
'rest_framework',

'authors.apps.authentication',
'authors.apps.core',
'authors.apps.profiles',
'rest_framework_swagger',
]

MIDDLEWARE = [
Expand Down
27 changes: 27 additions & 0 deletions authors/urls 2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""authors URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.urls import include, path
from django.contrib import admin
from rest_framework.schemas import get_schema_view
from rest_framework_swagger.renderers import SwaggerUIRenderer, OpenAPIRenderer

schema_view = get_schema_view(title='AUTHORS HAVEN API', renderer_classes=[OpenAPIRenderer, SwaggerUIRenderer])

urlpatterns = [
path('admin/', admin.site.urls),
path('api/', include(('authors.apps.authentication.urls', "api-authenticate"), namespace='authentication')),
path('', schema_view, name='docs')
]
6 changes: 5 additions & 1 deletion authors/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@
"""
from django.urls import include, path
from django.contrib import admin
from rest_framework.schemas import get_schema_view
from rest_framework_swagger.renderers import SwaggerUIRenderer, OpenAPIRenderer

schema_view = get_schema_view(title='AUTHORS HAVEN API', renderer_classes=[OpenAPIRenderer, SwaggerUIRenderer])

urlpatterns = [
path('admin/', admin.site.urls),
path('api/', include(('authors.apps.authentication.urls', "api-authenticate"), namespace='authentication')),
path('', schema_view, name='docs')
]

0 comments on commit 26376de

Please sign in to comment.