Skip to content

Commit

Permalink
Merge b2a407a into b56cb36
Browse files Browse the repository at this point in the history
  • Loading branch information
joelmugaya committed Apr 25, 2019
2 parents b56cb36 + b2a407a commit 55a29e1
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 13 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ python:
services:
- postgresql

env:
- DB=postgres
- ALLOWED_HOSTS=iamjoel

install:
- pip install -r requirements.txt

Expand Down
3 changes: 3 additions & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
release: python manage.py makemigrations
release: python manage.py migrate
web: gunicorn authors.wsgi --log-file -
41 changes: 29 additions & 12 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
{
"addons": [

],
"buildpacks": [

],
"name": "Ah-backend-guardians",
"scripts": {},
"env": {
"DB_HOST": {
"required": true
},
"DB_NAME": {
"required": true
},
"DB_PASS": {
"required": true
},
"DB_USER": {
"required": true
},
"DB_PORT": {
"required": true
},
"ALLOWED_HOSTS": {
"required": true
},
"DB": {
"required": true
}
},
"formation": {
},
"name": "ah-backend-invictus",
"scripts": {
},
"stack": "heroku-18"
"formation": {},
"addons": [
"heroku-postgresql"
],
"stack": "heroku-18",
"buildpacks": []
}
2 changes: 2 additions & 0 deletions authors/apps/authentication/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
LoginAPIView, RegistrationAPIView, UserRetrieveUpdateAPIView
)

app_name = "authentication"

urlpatterns = [
path('user/', UserRetrieveUpdateAPIView.as_view()),
path('users/', RegistrationAPIView.as_view()),
Expand Down
18 changes: 17 additions & 1 deletion authors/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"""

import os
import dj_database_url
from decouple import config


# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
Expand All @@ -24,10 +27,12 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []
ALLOWED_HOSTS = config('ALLOWED_HOSTS', cast=lambda v: [
s.strip() for s in v.split(',')])

# Application definition


INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
Expand Down Expand Up @@ -90,6 +95,9 @@
}
}

if os.environ.get("DB") == "heroku":
DATABASES['default'] = dj_database_url.config(default=config("DATABASE_URL"))

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

Expand Down Expand Up @@ -141,3 +149,11 @@
'EXCEPTION_HANDLER': 'authors.apps.core.exceptions.core_exception_handler',
'NON_FIELD_ERRORS_KEY': 'error',
}

#heroku deploy settings
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = os.path.join(PROJECT_ROOT, "staticfiles")

# Extra places for collectstatic to find static files.
STATICFILES_DIRS = (os.path.join(PROJECT_ROOT, "static"),)
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
Empty file added authors/static/__init__.py
Empty file.
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ certifi==2019.3.9
chardet==3.0.4
coverage==4.5.3
coveralls==1.7.0
dj-database-url==0.5.0
Django==2.1
django-cors-middleware==1.3.1
django-extensions==2.1.6
djangorestframework==3.9.2
docopt==0.6.2
gunicorn==19.9.0
idna==2.8
more-itertools==7.0.0
pluggy==0.9.0
Expand All @@ -18,7 +20,10 @@ py==1.8.0
PyJWT==1.7.1
pytest==4.4.1
pytest-cov==2.6.1
python-decouple==3.1
pytz==2019.1
requests==2.21.0
six==1.12.0
sqlparse==0.3.0
urllib3==1.24.2
whitenoise==4.1.2

0 comments on commit 55a29e1

Please sign in to comment.