-
Notifications
You must be signed in to change notification settings - Fork 0
Site Development & Documentation
###Step 1: Pre-requisites (Get these if you do not have them already!)### Python 3.0 or newer
https://www.python.org/downloads/
Git
I recommend getting Homebrew for installing packages on mac (http://brew.sh/)
If you have Homebrew just type brew install git into your command line.
If you do not have Homebrew, https://git-scm.com/book/en/v1/Getting-Started-Installing-Git.
PostgreSQL
Download the zip, unzip it, and move the PostgreSQL app into your Applications folder.
Open a terminal and from the command line open the ~/.bash_profile file with whatever editor you want.
Add this line to your ~/.bash_profile file:
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/bin
Save and close the file.
To check that you can now access PostgrSQL from the command line open a new terminal window and type psql. You should now see something like this:
If you do, you're all set. Type \q into the terminal and hit enter to exit from the psql shell.
Other: https://www.postgresql.org/download/
VirtualEnv
Once you have Python on your system, type pip3 install virtualenv into your command line. Virtualenv will let you create a virtual environment for you to install packages into for development. We will set one up further down in this wiki.
###Step 2: Set Up a PostgreSQL Database###
Once you installed PostgreSQL, launch it.
On mac you should see this window, and a small elephant in your top bar:
Open your terminal and type psql and you should see something like this:
Execute the following commands in your terminal one at a time to set up the local database you will use for this site development and testing:
CREATE DATABASE steganography;
CREATE USER team WITH PASSWORD 'password';
ALTER ROLE team SET client_encoding TO 'utf8';
ALTER ROLE team SET default_transaction_isolation TO 'read committed';
ALTER ROLE team SET timezone TO 'UTC';
ALTER USER team CREATEDB;
GRANT ALL PRIVILEGES ON DATABASE steganography TO team;
\q
You now have a database named steganography that you will be using locally any time you work on the site. Whenever you plan on working on the site, launch the PostgreSQL app and you are good to go.
###Step 3: Get Files from the git Repository Site-Dev Branch###
In your terminal, cd into a directory you plan on working out of for this project.
Type git clone https://github.com/dfish13/stegasaurus.git to clone the repository into your directory.
cd stegasaurus to move into the stegasaurus project repo.
If you type git branch you should see master as the only branch at the moment.
Type git branch site-dev.
If you type git branch you should now see *master and site-dev listed. The * next to master means that you are currently in that branch.
Type git checkout site-dev to switch to the site-dev branch.
Type git pull origin site-dev to make sure your site-dev branch is up to date with the remote site-dev branch.
Now, whenever you need to pull from site-dev type git pull origin site-dev.
Please, BEFORE YOU COMMIT OR PUSH ANYTHING check in Slack or via text if anyone is working out of the site-dev branch at the same time as you. If they are, and you need to commit, let them know you are going to commit and tell them to pull after you do!!
To pull from site-dev type git pull origin site-dev
To see changes in your branch type git status.
To add files you want to commit type git add FILENAME to add a specific file to the commit.
To commit, type git commit -m " TYPE A MESSAGE HERE ABOUT WHAT YOU ARE COMMITTING " but keep the quotation marks.
To push, type git push origin site-dev
Refer to the git docs or Google if you want to know how to do other things.
###Step 4: Set up a VirtualEnv###
Make sure you are in the directory you planned on working out of from step 3 (if you are still within the stegasaurus directory, type cd .. to get out of it.) and type virtualenv -p python3 steg-venv
This will create a virtual environment named steg-venv which you will work out of for this projects development.
To activate the virtual environment, type source steg-venv/bin/activate.
You should now see the name of your virtual environment, which is active:
To deactivate a virtual environment type deactivate from any directory. But for now, leave it activated.
###Step 5: Install Django and Other Requirements into your Virtual Environment###
cd back into the stegasaurus repo directory and type ls, you should see a file named requirements.txt among other things.
Type pip3 install -r requirements.txt
You should now have Django, Psycopg2, Pillow, and Numpy installed within your virtual environment.
FYI: Whenever you are going to interact with the site files or develop for the site you MUST activate this virtual environment so that you have access to Django and the other packages!
###Step 6: Migrate the Database into your Local Branch Copy of the Site###
Assuming you are still within the stegasaurus repo directory, cd site to go into the site directory. This is where all of the Django site project files are.
If you run ls you should see a directory called main, a file called manage.py and a directory called stegasaurus.
Execute the following commands to migrate the database we created earlier into your local project:
python manage.py makemigrations main
python manage.py migrate
###Step 7: Create a Super User for Access to the Admin Page.###
Assuming you are still within the site directory, type python manage.py createsuperuser. You will be prompted to enter a username, an email, and a password twice.
I recommend the following:
username: admin
email: admin@steg.com
password:
###Step 8: Check if Everything Works!###
Type python manage.py runserver while within the site directory to run the project server. You should see something like this:
This means that the local project is successfully running.
Open a browser and in the URL bar type http://127.0.0.1:8000
If you see something like the image below, everything is working! You're done setting up.
To access the admin side of the site, in your URL type http://127.0.0.1:8000/admin and log in with the super user credentials we created in step 7.
Please, BEFORE YOU COMMIT OR PUSH ANYTHING check in Slack or via text if anyone is working out of the site-dev branch at the same time as you. If they are, and you need to commit, let them know you are going to commit and tell them to pull after you do!!
If you have ANY issues or questions, please let Deborah know and she will help try resolve it.
If you look through the site directory in this repo you will notice there is a directory called main and a directory called stegasaurus. stegasaurus is the Django project overall. The directory called main is our "main app" which holds all of our views, templates, forms, etc. for the site.
(Assuming Linux/Unix or OSX environment... let me know if you have issue with Windows we can try there.)
Activate your virtual environment with source VIRTUALENV_NAME/bin/activate.
Go into the site directory within the stegasaurus repo.
You should now be in stegasaurus/site/. If you do ls you should see manage.py among a couple of other files - this means you are in the right place. From where you are, execute this command python manage.py runserver. You should see the following message in your terminal:
If you do, open your browser and go to http://127.0.0.1:8000/. You should now be able to interact with the site.
To access the admin side of the site:
Go to http://127.0.0.1:8000/admin and log in with the super user credentials you should have already created if you followed my steps above.
##Paths to important directories and files needed to work on the site are listed below.#
Site/Database Settings: cd site/stegasaurus/settings.py
Database Models: cd site/main/models.py
Adding/Modifying Views: cd site/main/views.py
Site URLS: cd site/main/urls.py
Site Templates (html): cd site/main/templates/main/<page>.html
Site Static Files (images, CSS, JavaScript ...): cd site/main/static/main/





