From f5c84efd37085695732803b28d4a74cc05042e0e Mon Sep 17 00:00:00 2001 From: Mitch Riedstra Date: Mon, 6 Nov 2017 16:05:53 -0500 Subject: Rename config to config-example and allow it to be loaded if config does not exist. Define email settings in config. Remove Django admin from the Admin's Nav. --- app/.gitignore | 1 + app/app/settings.py | 14 +++++++++- app/config-example.yml | 47 ++++++++++++++++++++++++++++++++ app/config.yml | 37 ------------------------- app/dispatch/templates/dispatch/nav.html | 1 - 5 files changed, 61 insertions(+), 39 deletions(-) create mode 100644 app/config-example.yml delete mode 100644 app/config.yml (limited to 'app') diff --git a/app/.gitignore b/app/.gitignore index f543301..70e8d3e 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -2,3 +2,4 @@ db.sqlite3* media tmux.sh .ropeproject +config.yml diff --git a/app/app/settings.py b/app/app/settings.py index f24a6b3..7e41f74 100644 --- a/app/app/settings.py +++ b/app/app/settings.py @@ -18,7 +18,11 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) def get_default_config(): - return yaml.load(open(BASE_DIR + '/config.yml').read()) + if os.path.exists(BASE_DIR + '/config.yml'): + return yaml.load(open(BASE_DIR + '/config.yml').read()) + else: + print("Warning: loading example config! Create config.yml Soon!") + return yaml.load(open(BASE_DIR + '/config-example.yml').read()) CONFIG = {} @@ -47,6 +51,14 @@ ALLOWED_HOSTS = CONFIG['allowed_hosts'] ADMINS = CONFIG['admins'] +if CONFIG.get('SET_EMAIL'): + EMAIL_HOST = CONFIG['EMAIL_HOST'] + EMAIL_HOST_PASSWORD = CONFIG['EMAIL_HOST_PASSWORD'] + EMAIL_HOST_USER = CONFIG['EMAIL_HOST_USER'] + EMAIL_PORT = CONFIG['EMAIL_PORT'] + EMAIL_USE_TLS = CONFIG['EMAIL_USE_TLS'] + + AUTH_USER_MODEL = 'dispatchAuth.User' diff --git a/app/config-example.yml b/app/config-example.yml new file mode 100644 index 0000000..7954e08 --- /dev/null +++ b/app/config-example.yml @@ -0,0 +1,47 @@ +--- +# Postgres Example +# db_default: +# ENGINE: django.db.backends.postgresql +# NAME: dispatch +# USER: postgres +# PASSWORD: +# HOST: 127.0.0.1 +# PORT: 5432 +# MySQL Example +# db_default: +# ENGINE: django.db.backends.mysql +# NAME: dispatch_test +# USER: dispatch +# PASSWORD: ahB2lee5 +# HOST: 127.0.0.1 +# PORT: 3306 +# Sqlite example. Full path is recommended +db_default: + ENGINE: django.db.backends.sqlite3 + NAME: /home/mitch/scm/dispatch-tracker/app/db.sqlite3 + +allowed_hosts: + - localhost + - 127.0.0.1 + +static_root: '/full/path/to/static/root' + +debug: True + +# CHANGE THIS BEFORE USING IN PRODUCTION +SECRET_KEY: 'h$r_bwlp@#h#y#%&qhw-n=gb2%wva1d_h65+o94u&!a#%iv&lo' + +# These people will be emailed if debug = false +admins: + - 'bob@example.com' + + + +# Email settings won't be loaded from this file if this is false +SET_EMAIL: False +# Email settings, edit for your needs +EMAIL_HOST: smtp.example.com +EMAIL_HOST_PASSWORD: p@$$w0rd9876543210 +EMAIL_HOST_USER: django@example.com +EMAIL_PORT: 2525 +EMAIL_USE_TLS: True diff --git a/app/config.yml b/app/config.yml deleted file mode 100644 index 8c39278..0000000 --- a/app/config.yml +++ /dev/null @@ -1,37 +0,0 @@ ---- -# Postgres Example -db_default: - ENGINE: django.db.backends.postgresql - NAME: dispatch - USER: postgres - PASSWORD: - HOST: 127.0.0.1 - PORT: 5432 -# MySQL Example -# db_default: -# ENGINE: django.db.backends.mysql -# NAME: dispatch_test -# USER: dispatch -# PASSWORD: ahB2lee5 -# HOST: 127.0.0.1 -# PORT: 3306 -# Sqlite example. Full path is recommended -# db_default: -# ENGINE: django.db.backends.sqlite3 -# NAME: /home/mitch/scm/dispatch-tracker/app/db.sqlite3 - -allowed_hosts: - - localhost - - 127.0.0.1 - -static_root: '/full/path/to/static/root' - -debug: True - -# CHANGE THIS BEFORE USING IN PRODUCTION -SECRET_KEY: 'h$r_bwlp@#h#y#%&qhw-n=gb2%wva1d_h65+o94u&!a#%iv&lo' - -# These people will be emailed if debug = false -admins: - - 'bob@example.com' - diff --git a/app/dispatch/templates/dispatch/nav.html b/app/dispatch/templates/dispatch/nav.html index 39acb38..a5f09e5 100644 --- a/app/dispatch/templates/dispatch/nav.html +++ b/app/dispatch/templates/dispatch/nav.html @@ -4,7 +4,6 @@ {% if request.user.is_superuser %}
  • Drivers
  • Customers
  • -
  • DjangoAdmin
  • {% else %}
  • Summary
  • My Account
  • -- cgit v1.2.3