Now, we're going to clone down a copy of the UTA_Apps codebase from git.gmu.edu, the SRCT code respository.
Configure your ssh keys by following the directions at git.gmu.edu/help/ssh/README.
Now, on your computer, navigate to the directory in which you want to download the project (perhaps one called development/ or something similar), and run
`$ git clone git@git.gmu.edu:srct/UTA_Apps.git`
Finally, install these packages from the standard repositories:
If prompted to install additional required packages, install those as well.
When prompted to set your mysql password, it's advisable to set it as the same as your normal superuser password.
### The Virtual Enviornment
Virtual environments are used to keep separate project packages from the main computer, so you can use different versions of packages across different projects and ease deployment server setup.
It's often recommended to create a special directory to store all of your virtual environments together (ie. development/virtualenv/), though they can be placed wherever is most convienent.
Run:
`$ sudo pip install virtualenv`
to install virtualenv system-wide.
Then in your virtual environment directory run:
`$ virtualenv UTA_Apps`
to create your virtual environment.
Activate it by typing:
`$ source UTA_Apps/bin/activate`
If you ever need to exit your virtual environment, simply run:
`$ deactivate`
Now, the packages you need to install for Go are in in the top level of the project's directory structure(UTA_Apps/).
Run:
`$ pip install -r requirements.txt`
to install all of the packages needed for the project.
### Database Configuration
Go is configured for use with a mysql database.
Load up the mysql shell by running
`$ mysql -u root -p insert_password_here`
and putting in your mysql password.
Create the database by running:
`> CREATE DATABASE UTA_Apps;`
You can choose a different name for your database if you desire.
Double check your database was created by running:
`> SHOW DATABASES;`
Though you can use an existing user to access this database, here's how to create a new user and give them the necessary permissions to your newly created database:
`> CREATE USER 'UTA'@'localhost' IDENTIFIED BY 'password';`
For local development, password strength is less important, but use a strong passphrase for deployment. You can choose a different username.
Run:
`> GRANT ALL ON UTA_Apps.* TO 'UTA'@'localhost';`
This allows your database user to create all the tables it needs on the UTA_Apps database. (Each model in each app's models.py is a separate table, and each attribute a column, and each instance a row.)
Run:
`> GRANT ALL ON test_UTA_Apps.* TO 'UTA'@'localhost'; FLUSH PRIVILEGES;`
When running test cases, django creates a test database so your 'real' database doesn't get screwed up. This database is called 'test_' + whatever your normal database is named. Note that for permissions it doesn't matter that this database hasn't yet been created.
The .* is to grant access all tables in the database, and 'flush privileges' reloads privileges to ensure that your user is ready to go.
Exit the mysql shell by typing:
`> exit`
### Additional Setup
Now, to configure your newly created database with the project settings, and set up your project's cryptographic key, copy the secret.py.template in settings/ to secret.py. Follow the comment instructions provided in each file to set your secret key and database info.
Also copy settings.py.template to settings.py. You will need to set DEBUG mode to True in order to view more details when things go awry.
Change directory into uta_apps/uta_apps and run:
`$ python manage.py makemigrations`
to create the tables and rows and columns for your database. This command generates sql code based on your database models.
Then run:
`$ python manage.py migrate`
to execute that sql code and set up your database. Migrations also track how you've changed your models over the life of your database, which allows you to make changes to your tables without screwing up existing information.
Finally, run:
`$ python manage.py createsuperuser`
to create an admin account, using the same username and email as you'll access through CAS. This means your 'full' email address, for instance gmason@masonlive.gmu.edu. Your password will be handled through CAS, so you can just use 'password' here.
(If you accidentally skip this step, you can run python manage.py shell and edit your user from there. Select your user, and set .is_staff and .is_superuser to True, then save.)
Finally, within 'uta_apps/uta_apps' run:
`$ python manage.py runserver`
to start the site. Open your preferred web browser and navigate to 127.0.0.1:8000/ to see the site!