- Clone the repository
- (Recommended) Create a virtualenv (Instructions)
- Try to name the virtualenv venv as that name has been added in gitignore
- Activate the virtualenv (Note - Make sure to always activate the virtualenv before working with new terminals)
- Run
pip install -r requirements.txtto install all of the required libraries - Run the following commands to set up the database
- Run
python manage.py makemigrations apito create new migrations - Run
python manage.py migrateto set up the database - Run
python manage.py set_up_databaseto create necessary objects in the database
- Run
- Run
python manage.py runserverto start the django server - Open a new terminal and activate the virtualenv
- Run
cd frontend && npm install- Debug any issues that may come up regarding npm or node versions
- Run
npm run devto start the development server
You should now be set up to develop locally. Go to localhost:8000 on a browser and you should see the portal hosted locally. Changes should automatically show on the server and there's no need to re-run the server unless you install new packages.
If changes are made that affect the database, run:
- Run
python manage.py makemigrationsto generate new migration files - Run
python manage.py migrateto update the database
In deployment:
ssh -i "key_pair_1.pem" ubuntu@52.9.199.73to access the remote servercd hkn-portalto enter repository directorygit pullto grab latest repositorycd frontend&npm run buildto create build rollupcd ..&source venv/bin/activate&python manage.py collectstaticto collect static files- If changes to database structure:
python manage.py makemigrations&python manage.py migrate sudo service apache2 restartto restart server with changes
Custom python manage.py commands:
setUpDatabasecreates a necessary groups and objects neededcreatesuperusercreates a superusergenerate_inducteesgenerates a json file containing emails of inducteesinduct file.jsoninduct inductees (change their role to members)- JSON file format is [{"email": "example@domain.com"}]
promote_officer file.jsonpromotes members to officers- JSON file format is [{"email": "example@domain.com", "position": "position"}]
newinductionclasscreates a new induction class object & related event for points rolloverinducteeformgenerates a new url for inductee forms based on current induction classclearoutreachhours file.jsonremoves all outreach hours for given users- JSON file format is [{"email": "example@domain.com"}]