From ff7ab3fe621fb4743a0aad3170652dc44c1e8fe3 Mon Sep 17 00:00:00 2001 From: Ben Crocker Date: Sat, 18 Sep 2021 12:36:09 -0400 Subject: [PATCH] Added TARGET_HOST env variable. --- CodeReview/settings.py | 13 +++++-------- README.md | 14 ++++++++------ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/CodeReview/settings.py b/CodeReview/settings.py index 9eaa1c6..bbbb5a4 100644 --- a/CodeReview/settings.py +++ b/CodeReview/settings.py @@ -1,12 +1,6 @@ import os from pathlib import Path -""" - Env variables are as follows: - SECRET_KEY: the key to use as the secret key - DEV_STAGE: The current stage of development we're on. Dev, Production, GH_TEST -""" - BASE_DIR = Path(__file__).resolve().parent.parent STAGE = os.getenv("DEV_STAGE", "Dev") @@ -15,7 +9,10 @@ DEBUG = STAGE != "Prod" SECRET_KEY = 'django-insecure-1&=3d#^^j*!8)r5y8tuh(t#rp6*(jwbx%90k-ir5c*2j4$s$o%' if DEBUG else os.getenv("SECRET_KEY") -ALLOWED_HOSTS = [] +if DEBUG: + ALLOWED_HOSTS = ['127.0.0.1', 'localhost'] +else: + ALLOWED_HOSTS = [os.getenv("TARGET_HOST")] INSTALLED_APPS = [ 'django.contrib.admin', @@ -43,7 +40,7 @@ ROOT_URLCONF = 'CodeReview.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [BASE_DIR / 'templates'], + 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ diff --git a/README.md b/README.md index 27819c9..44d06b8 100644 --- a/README.md +++ b/README.md @@ -8,12 +8,13 @@ Basic material design layout and UI with primary, secondary, and accent colors. ## Technical Using active directory, users will log in to post request for reviews, on posting an email will be sent to seniors and the instructor. Once a senior accepts the review, the instructor will receive an email. Upon completion of the code review, the instructor will get a final email with the notes the senior has given. ### Environment Variables -- DEV_STAGE: The current stage of development options are: Dev, Prod, and GitHub +- DEV_STAGE: The current stage of development options are: Dev, Prod, and GH_TEST +- TARGET_HOST: The host you'd like to use in production. This wil be the only value in ALLOWED_HOSTS in production. - SECRET_KEY: Key to use in production as the django secret key - EMAIL_HOST: The email server host we're connecting to - EMAIL_USER: The username of the email we'll use to send notifications - EMAIL_PASS: The password to use for the email -- DB_HOST: The host for the database we'll use (MySQL Type) +- DB_HOST: The host for the database we'll use - DB_NAME: The name for the db we'll use - DB_PASS: The password for the db we'll use - LDAP_URL: The url of the ActiveDirectory Server we want to use for auth @@ -25,11 +26,12 @@ Using active directory, users will log in to post request for reviews, on postin - [Jquery](https://jquery.com/) - [FontAwesome](https://fontawesome.com/) ## Running -### Development -Set the env variable DEV_HOST to the host you want to host in development +### Development Then, simply run the django run command: -```python manage.py runserver YOUR_HOST:8080``` +```python manage.py runserver YOUR_HOST:PORT``` Development is insecure and inefficient, only use when testing +#### Testing on something other than localhost +For testing this site on something other than the local machine (like a local server), you'll need to add your IP to ALLOWED_HOSTS in settings.py ### Production Will require an SQL server to connect to, an ActiveDirectory server, an email to send notifications from, and a webserver to run the django code on. Set up your webserver and then point it to ```CodeReview/wsgi.py```. @@ -37,4 +39,4 @@ This will require [environment variables](https://github.com/Bwc9876/CodeReview# ### Tests Tests are available through the normal django interface, simply run ``` python manage.py runtests ``` - +Note that tests won't work if django is unable to create a separate database to test with. -- knotmirror 0.0.1