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.
If you're unfamiliar with CSM and/or its web applications, check out this repository's releases for a peek at what our web applications look like and what we've been working on lately.
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.
pyenv
or asdf
(with asdf-python
), so that you can use a consistent python version for csm_web
, and another python version for your other projects.poetry
npm
nvm
, n
, or asdf
(with asdf-nodejs
), so that you can use a consistent node/npm version for csm_web
, and another verison for your other projects.aws configure
) This will prompt an interactive session to enter login credentials.us-east-1
json
Other miscellaneous requirements will be installed by the commands below.
To ensure package version consistency and avoid polluting your global package installations, we highly recommend running the server with a virtual environment. Python's standard library includes venv, so you do not need to install anything new here.
Firstly, make sure you have the right python version (see runtime.txt
for the expected python version to install). If you're using pyenv
to manage python versions (this is recommended), you can install the specified python version with pyenv install <version>
.
Next, make sure that your current python version is correct (i.e. as specified in the previous section); if it is different, then change to the correct python version. That is, with pyenv
, run pyenv local <version>
; with asdf
, run asdf local python <version>
.
Finally, run ./setup.sh
. This will install additional requirements needed by the server, and set up some necessary environment variables. In particular, the setup script installs all dependencies locally and builds the Docker images.
Note that generally, you should not need to run setup.sh
after first setting up the repository.
To start the Django server and other services, make sure Docker is up and run docker compose up -d
. This will start Django, automatically compile and watch frontend files, and start a development database. (The -d
puts the process in the background.)
To generate test data, run docker compose exec django python3 csm_web/manage.py createtestdata
. In general, if you'd like to run any commands in the Django docker container, run docker compose exec django <command>
. (You can make an alias in your shell if you'd like to avoid typing all of this each time.)
If all of the above has worked, visit http://localhost:8000 in your browser and you should see a log in screen; don't actually use this to actually log in locally. Visit http://localhost:8000/admin/ to log in instead.
Any changes will automatically reload the server in the docker containers, but you will usually need to force refresh (ctrl + shift + R
or cmd + shift + R
on most browsers) for frontend changes to be reflected (this clears the browser cache for the page).
During development, you should use the virtual environment as much as possible---while Docker makes this less necessary, your choice of editor may require the dependencies in the virtual environment. To activate the virtual environment, you can use poetry shell
(this will start a new nested shell instance), or you can use source .venv/bin/activate
(more generally, source $(poetry env info --path)/bin/activate
).
setup.sh
Errorssetup.sh
(you should be able to do this even after attempting to run pip/npm commands already).
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
psycopg2
, console output displays ld: library not found for -lpq
or similar./setup.sh
or pip3 install
I'm getting a psycopg2
install error that looks like this:Error: pg_config executable not found.
pg_config is required to build psycopg2 from source. Please add the directory
containing pg_config to the $PATH or specify the full executable path with the
option:
./setup.sh
, this happens after pip3 install
runs./setup.sh:41: no such file or directory: /Users/jhshi/Documents/csm/csm_web/venv/.project_dir
./setup.sh:44: no such file or directory: /Users/jhshi/Documents/csm/csm_web/venv/bin/activate
./setup.sh:47: no such file or directory: /Users/jhshi/Documents/csm/csm_web/venv/bin/activate
/admin
page?./setup.sh
script will create a user with username demo_user
and password pass
. You can access it by signing in through the admin page.python3 csm_web/manage.py shell
):from scheduler.models import *
# replace "my_username" with the prefix of your Berkeley email, as in "my_username@berkeley.edu"
user = User.objects.get(username="my_username")
user.is_staff = True
user.is_superuser = True
user.save()
pip
Try replacing pip
with pip3
instead.
Error 401: invalid_client
The OAuth client was not found.
OAuth secrets are sourced from the heroku repository: you'll need to log in to heroku, add the
appropriate remote, rerun setup.sh
, and then reactivate your virtualenv.
runserver
, long stack trace ending with this:django.db.utils.OperationalError: could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
Your PostgreSQL server is likely not running. On MacOS, run brew services start postgres
before invoking runserver
again; on Unix, run sudo service postgresql restart
before invoking runserver
again.