Skip to content

Commit

Permalink
base project structured
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Depoix committed Mar 29, 2017
1 parent 741ae57 commit 3da1a52
Show file tree
Hide file tree
Showing 16 changed files with 62 additions and 11 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.idea
virtualenv
secrets.json
__pycache__
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# GOTO -> Cloud: Making Cloud Migration easy

under development!
1 change: 1 addition & 0 deletions goto_cloud/api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions goto_cloud/settings/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

21 changes: 14 additions & 7 deletions goto_cloud/settings.py → goto_cloud/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.10/ref/settings/
"""

import os
import json

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
PROJECT_DIR = os.path.dirname(BASE_DIR)
SECRETS_FILE_PATH = PROJECT_DIR + '/secrets.json'


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
SECRETS = json.load(open(SECRETS_FILE_PATH))

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'b+(6_@omqo!q4k()o2_2hg5!&8utnvp&(^4ugu_)mnl6uzm8*3'
SECRET_KEY = SECRETS.get('django_secret', '')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
Expand Down Expand Up @@ -67,19 +67,26 @@
},
]

WSGI_APPLICATION = 'goto_cloud.wsgi.application'
WSGI_APPLICATION = 'goto_cloud.wsgi.prod.application'


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

DATABASES = {
DEFAULT_DATABASE = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}

DATABASES = {
'default': {
**SECRETS.get('database'),
'ENGINE': 'django.db.backends.postgresql_psycopg2',
}
} if SECRETS.get('database') else DEFAULT_DATABASE


# Password validation
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
Expand Down
3 changes: 3 additions & 0 deletions goto_cloud/settings/local.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from settings.base import *

ENVIRONMENT = 'local'
4 changes: 4 additions & 0 deletions goto_cloud/settings/prod.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from settings.base import *

DEBUG = False
ENVIRONMENT = 'prod'
3 changes: 3 additions & 0 deletions goto_cloud/settings/testing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from settings.base import *

ENVIRONMENT = 'testing'
1 change: 1 addition & 0 deletions goto_cloud/wsgi/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

4 changes: 3 additions & 1 deletion goto_cloud/wsgi.py → goto_cloud/wsgi/prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
"""

import os
import sys

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "goto_cloud.settings")
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'goto_cloud'))
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.prod")

application = get_wsgi_application()
10 changes: 7 additions & 3 deletions manage.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#!/usr/bin/env python
#!virtualenv/bin/python

import os
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "goto_cloud.settings")

if __name__ == '__main__':
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'goto_cloud'))
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings.testing' if sys.argv[1] == 'test' else 'settings.local')

try:
from django.core.management import execute_from_command_line
except ImportError:
Expand Down
5 changes: 5 additions & 0 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Django
django==1.10.6

# POSTGRES
psycopg2==2.7.1
1 change: 1 addition & 0 deletions requirements/local.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-r base.txt
1 change: 1 addition & 0 deletions requirements/prod.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-r base.txt
1 change: 1 addition & 0 deletions requirements/testing.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-r local.txt
10 changes: 10 additions & 0 deletions secrets.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"django_secret": "",
"database": {
"USER": "",
"HOST": "",
"PASSWORD": "",
"PORT": 5432,
"NAME": "goto_cloud"
}
}

0 comments on commit 3da1a52

Please sign in to comment.