/VIEW2.0-site

Primary LanguageJavaScriptMIT LicenseMIT

VIEW-Prototype

Link to VIEW 2.0 Website

Website Link: www.blindzonesafety.org

How to Run Website Locally on Computer

Set up a Virtual Environment

  1. Create a virtual environment using the command below.
python -m venv /path/to/environment_name
  1. Activate virtual environment. Navigate to directory where enviroment is located.
source environment_name/bin/activate

Set up the Repository

  1. Clone this repository and deploy the main branch.

  2. Navigate into the repository project folder.

  3. In terminal, run the line of code below to install all necessary packages. Make sure you are in your virtual environment.

pip install -r requirements.txt
  1. Create a file called .env and place in root directory of project folder. Copy in secret environment variables and add to .gitignore if not already there. For security, this file should never be committed or pushed to GitHub.

  2. Add your device IP address to the Digital Ocean database trusted sources.

    a. Log in to Digital Ocean using sign in with gmail.

    b. On the left side panel, click on Databases.

    c. Click on the database called db-postgresql-nyc3-27521.

    d. Click on the Settings tab, scroll down to Trusted Sources, and click Edit.

    e. Enter your device IP address and click Save. Typically, once you click into the input field, your IP address will show up automatically as a suggested IP.

Launching the Website

  1. To launch the local server, run the line below in the root directory of the project.
python manage.py runserver

Commands to Make Changes

Editing static files

When editing any static files, such as javascript files (.js) or CSS files (.css), your changes will not automatically show up on the local site or on the production site. Run the command below to push changes to the website storage on Digital Ocean where static files are stored. This must be done whether making changes to the local or production site.

python manage.py collectstatic --noinput

Editing other files

Changes made to the other files will be updated on the locally run website immediately upon refreshing. However, when ready to make changes to the production website, changes must be committed then pushed to the branch that the production website is sourcing (right now it is the main branch). After changes are pushed, Digital Ocean rebuilds and deploys the site, which can take anywhere from 4-8 minutes.

How to Access PostgresSQL in Terminal

Navigate to the command line and type in the following command, replacing the sections in <> with the correct values.

psql -h <REMOTE HOST> -p <REMOTE PORT> -U <DB_USER> <DB_NAME>