Skip to content

Commit

Permalink
Add LICENSE, clean up README, add setup script
Browse files Browse the repository at this point in the history
  • Loading branch information
noloerino committed Mar 4, 2019
1 parent db37312 commit 069c3b8
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 47 deletions.
9 changes: 9 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MIT License

Copyright (c) 2019 Computer Science Mentors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
72 changes: 34 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,35 @@
# CSM Web Applications
This repository is for the Django CSM Web project that contains the Scheduler
application (and possibly more applications to come).

## Install
We recommend running this with a Python virtual environment.

If you don't have virtualenv,
```
pip install virtualenv
```

To create the virtualenv, run
```
virtualenv venv
```
You may need to specify the Python version
(you can find the path to Python3 with `which python3`)
in which case run the following instead
```
virtualenv --python=/usr/local/bin/python3 venv
```

To create install dependencies,
```
source venv/bin/activate
pip install -r csm_web/requirements.txt
npm i
```

## Starting Django
To start the Django server,
```
npm run dev && python csm_web/manage.py runserver
```
To populate the database with test data,
```
python csm_web/manage.py createtestdata
```
This repository contains webapps that help support the infrastructure of CSM. Currently, it only holds Scheduler (our section signup and attendance system), but more are on the way.
## Installing
### Requirements
We don't know what specific minimum version you would need for any of the following software, but the most recent version of any of the below should work.

* Python 3.7
* [virtualenv](https://packaging.python.org/guides/installing-using-pip-and-virtualenv/) (`pip install virtualenv`)
* [black](https://black.readthedocs.io/en/stable/) (`pip install black`)
* [npm](https://www.npmjs.com/get-npm)
* [prettier](https://prettier.io/) (`npm install -g prettier`)
* [eslint](https://eslint.org/) (`npm install -g eslint`; `npm install -g eslint-plugin-react`)
* [Heroku CLI](https://devcenter.heroku.com/articles/heroku-cli#download-and-install) (`brew tap heroku/brew && brew install heroku`)

Other miscellaneous requirements will be installed by the commands below.

### Setup
To ensure package version consistency and avoid polluting your global package installations, we highly recommend running the server with [virtualenv](https://virtualenv.pypa.io/en/stable/) (`pip install virtualenv`).

From a terminal in the top level of the project directory, run `python3 -m virtualenv venv`.

To activate the environment, run `source venv/bin/activate`. You will need to run this command every time you open a new terminal.

Finally, run `./setup.sh`. This will install additional requirements needed by the server, and set up some necessary environment variables.

## Running
To start the Django server, run `python csm_web/manage.py runserver` and visit `localhost:8000` in your browser.

Run `python csm_web/manage.py createtestdata` to generate some test data.

*If you make any frontend changes*: run `npm run dev` to rebuild the frontend JS bundle (this has to be done manually at the moment).

## Troubleshooting
* OSX: error on running `pip`
* Try replacing `pip` with `pip3` instead.
9 changes: 0 additions & 9 deletions csm_web/csm_web/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,6 @@
},
}


if not os.environ.get("DEBUG_LOG_OFF"):
LOGGING["loggers"]["django.db.backends"] = {
"handlers": ["low-level"],
"level": "DEBUG",
"propagate": False,
}


if DJANGO_ENV == PRODUCTION:
# Security/HTTPS headers
# https://docs.djangoproject.com/en/2.1/ref/middleware/#module-django.middleware.security
Expand Down
49 changes: 49 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# #!/usr/bin/env bash
# # Sets up environment variables and such, assuming requirements already installed.
# # Kevin Svetlitski, rev. Jonathan Shi

# [ ! -f 'package.json' ] && echo 'You are in the wrong directory!' && exit 1
# [ -z "$VIRTUAL_ENV" ] && echo 'You must activate your virtualenv first!' && exit 1

# # Node and Python requirements
# npm i
# npm run dev
# pip3 install -r requirements.txt

# # Set up environment variables
# echo "Setting up environment variables..."
# echo "BUILDPACK_URL='https://github.com/heroku/heroku-buildpack-python'
# DJANGO_ENV=dev
# DEBUG_LOG_OFF='True'
# WEB_CONCURRENCY=4" > .env

# # Get a new key
# echo "Generating Django secret key..."
# export SECRET_KEY=$(echo "from django.core.management.utils import get_random_secret_key; \
# print(get_random_secret_key())" | python3 csm_web/manage.py shell)
# echo "SECRET_KEY='$SECRET_KEY'" >> .env

# # Must be pulled from Heroku (but not critical to running tests etc.)
# if [[ $(heroku whoami) ]]; then
# echo "Attempting to set OAUTH keys from heroku config..."
# echo $(heroku config:get SOCIAL_AUTH_GOOGLE_OAUTH2_KEY -s) >> .env
# echo $(heroku config:get SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET -s) >> .env
# else
# echo "Did not find Heroku CLI installation. OAUTH keys have not been set, so you will be unable to log in with your email."
# fi

# pwd > "$VIRTUAL_ENV/.project_dir"

# Slightly jank hack to get .env to source properly
cat <<EOF >> $VIRTUAL_ENV/bin/activate
# Scheduler: get variables in .env
while read v; do
export \$v
done < $(pwd)/.env
EOF

# # TODO put precommit hooks in git?
# echo "Getting precommit hooks..."
# curl "http://inst.eecs.berkeley.edu/~cs199-eug/pre-commit" -o .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit

echo "Done installing. Please reactivate your virtualenv before running any more commands."

0 comments on commit 069c3b8

Please sign in to comment.