Skip to content

Repository files navigation

Cal-B/C

This tool calculates values based on Cal-B/C workbooks. It also provides automation around filling out workbooks.

Installation

Note

All commands below should be run inside this directory.

This application requires uv to be installed. This can be installed using asdf:

$ asdf plugin add uv
$ asdf install

Install dependencies using uv:

$ uv sync

Copy .env.example to .env and fill in the secret values in the .env file:

$ cp .env.example .env

Set your Google Cloud project and login:

$ gcloud config set project cal-itp-data-infra-staging # you will want to unset this later with `gcloud config unset project`
$ gcloud auth application-default login --login-config=iac/login.json --quiet

Create the database and run migrations:

$ uv run manage.py sqlcreate | psql
$ uv run manage.py migrate

Note

If you don't have postgresql, run brew install postgresql or visit https://www.postgresql.org/ for more information.

If you run into the error database "database_name" does not exist, you may need to create it manually running createdb <database_name>.

To check if your database was created, run psql -l.

In another terminal tab, start the Tailwind build process:

$ uv run manage.py tailwind build
$ uv run manage.py tailwind watch

Then, collect all the static files and start the Django server:

$ uv run manage.py collectstatic
$ uv run manage.py runserver

Finally, start the Django tasks worker:

$ uv run manage.py db_worker

Now, visit the server at http://localhost:8000.

Running tests

In order to run tests, you will need to ensure that Playwright is installed:

$ uv run playwright install

Now, run the tests:

$ uv run manage.py test

Note

You can run only the web application tests using:

$ uv run manage.py test tests/cal_bc

Note

The Project System Test includes Accessibility checks. Remember to include new pages to the test. Reports can be found locally in axe-results/.

Linting

This project uses ruff to lint code. To run linting and apply fixes:

$ uv run ruff check --fix

Managing Django in Cloud Run

To run manage.py commands on the deployed Cloud Run instance, use the cal-bc-staging-manage Cloud Run Job.

For example, if you want to migrate the models app back to a specific migration, you would locally run:

$ uv run manage.py migrate models 0013_subsection_description

The Cloud Run Jobs equivalent using cal-bc-staging-manage is:

$ gcloud run jobs execute cal-bc-staging-manage --args migrate,models,0013_subsection_description --wait

Administering the site locally

In order to access the admin site at http://localhost:8000/admin, you need to create a superuser for your DOT login:

$ uv run manage.py createsuperuser
Username (leave blank to use 'yourname'): Your.Name@dot.ca.gov
Email address: Your.Name@dot.ca.gov
Password: ********
Password (again): ********

Now, when you visit the admin site, you can log in with your DOT account as usual.

Note

If you forget to add your user before this point, the Azure Entra ID login package will automatically add a user and disallow access. You will need to either manually make your user a superuser or delete your user account.

To access or make changes to your local database, run:

$ uv run manage.py dbshell

To reset your local database, run:

$ uv run manage.py reset_db

License

This tool is licensed under the terms of the GNU Affero General Public License.

About

Cal-B/C App

Resources

Stars

0 stars

Watchers

6 watching

Forks

Releases

Packages

Used by

Contributors

Languages