You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Migrate to poetry, update dependencies, add pre-commit
Migrate to poetry for dependency management
Setup pre-commit hooks
Fix django settings in upgrading to 4.x
Add __init__ files as necessary to keep module structure
Remove old test cases, reformat edited files
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.
3
4
4
5
If you're unfamiliar with CSM and/or its web applications, check out [this repository's releases](https://github.com/csmberkeley/csm_web/releases) for a peek at what our web applications look like and what we've been working on lately.
5
6
6
7
## Installing
8
+
7
9
### Requirements
10
+
8
11
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.
* We use an S3 bucket to store course resources. See [here](https://aws.amazon.com/s3/) to get started.
21
-
* Log in to AWS CLI (`aws configure `) This will prompt an interactive session to enter login credentials.
22
-
* AWS Access Key ID: (ask tech chair)
23
-
* AWS Secret Access Key: (ask tech chair)
24
-
* Default region name: us-east-1
25
-
* Default output format: json
13
+
- Python 3.9.13
14
+
- It is recommended that you use [`pyenv`](https://github.com/pyenv/pyenv) to manage python versions, so that you can use a consistent python version for `csm_web`, and another python version for your other projects.
- It is recommended that you use [`nvm`](https://github.com/nvm-sh/nvm) to manage node/npm versions, so that you can use a consistent node/npm version for `csm_web`, and another verison for your other projects.
- We use an S3 bucket to store course resources. See [here](https://aws.amazon.com/s3/) to get started.
23
+
- Log in to AWS CLI (`aws configure`) This will prompt an interactive session to enter login credentials.
24
+
- AWS Access Key ID: (ask tech chair)
25
+
- AWS Secret Access Key: (ask tech chair)
26
+
- Default region name: `us-east-1`
27
+
- Default output format: `json`
26
28
27
29
Other miscellaneous requirements will be installed by the commands below.
28
30
29
31
### Setup
30
-
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`).
31
32
32
-
From a terminal in the top level of the project directory, run `python3 -m virtualenv venv`.
33
+
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](https://docs.python.org/3/library/venv.html), so you do not need to install anything new here.
34
+
35
+
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>`.
36
+
37
+
From a terminal in the top level of the project directory, run `python3 -m venv venv`; if your system python version is different from the version required here, and you're using `pyenv`, run `PYENV_VERSION=<version> python3 -m venv venv` instead (for example, `PYENV_VERSION=3.9.13 python3 -m venv venv`). This will initialize a new virtual environment in the `venv/` folder, with the correct base python version.
33
38
34
39
To activate the environment, run `source venv/bin/activate`. You will need to run this command every time you open a new terminal.
35
40
36
-
Finally, run `./setup.sh`. This will install additional requirements needed by the server, and set up some necessary environment variables.
41
+
Finally, run `./setup.sh`. This will install additional requirements needed by the server, and set up some necessary environment variables. You should _not_ be running this script after it has succeeded and set up the environment for the first time.
37
42
38
43
## Running
39
-
To start the Django server, run `python csm_web/manage.py runserver` and visit `localhost:8000` in your browser.
40
44
41
-
Run `python csm_web/manage.py createtestdata` to generate some test data. If you ran `./setup.sh`,
45
+
To start the Django server, run `python3 csm_web/manage.py runserver` and visit `localhost:8000` in your browser.
46
+
47
+
Run `python3 csm_web/manage.py createtestdata` to generate some test data. If you ran `./setup.sh`,
42
48
this was done for you.
43
49
44
-
*If you are working on the frontend*:
50
+
_If you are working on the frontend_:
45
51
46
52
Run `npm run watch`, which will automatically rebuild the JS bundle if any changes to the frontend JS are detected.
47
53
Alternatively you can run `npm run dev` manually each time you make changes to the frontend.
48
54
49
55
## Troubleshooting
56
+
50
57
### `setup.sh` Errors
51
-
* The following errors are likely caused by some quirks in our build system - if you set up a new virtual environment through normal commands, you may run into them. The solution for all of these should be to run `setup.sh` (you should be able to do this even after attempting to run pip/npm commands already).
52
-
*`django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.`
53
-
* When installing `psycopg2`, console output displays `ld: library not found for -lpq` or similar
54
-
* During `./setup.sh` or `pip3 install` I'm getting a `psycopg2` install error that looks like this:
58
+
59
+
- The following errors are likely caused by some quirks in our build system - if you set up a new virtual environment through normal commands, you may run into them. The solution for all of these should be to run `setup.sh` (you should be able to do this even after attempting to run pip/npm commands already).
60
+
-`django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.`
61
+
- When installing `psycopg2`, console output displays `ld: library not found for -lpq` or similar
62
+
- During `./setup.sh` or `pip3 install` I'm getting a `psycopg2` install error that looks like this:
63
+
55
64
```
56
65
Error: pg_config executable not found.
57
-
66
+
58
67
pg_config is required to build psycopg2 from source. Please add the directory
59
68
containing pg_config to the $PATH or specify the full executable path with the
60
69
option:
61
70
```
62
-
* You need to install Postgres locally (see [this](https://stackoverflow.com/a/12037133) SO post)
63
-
* During `./setup.sh`, this happens after `pip3 install` runs
71
+
72
+
- You need to install Postgres locally (see [this](https://stackoverflow.com/a/12037133) SO post)
73
+
- During `./setup.sh`, this happens after `pip3 install` runs
74
+
64
75
```
65
76
./setup.sh:41: no such file or directory: /Users/jhshi/Documents/csm/csm_web/venv/.project_dir
66
77
./setup.sh:44: no such file or directory: /Users/jhshi/Documents/csm/csm_web/venv/bin/activate
67
78
./setup.sh:47: no such file or directory: /Users/jhshi/Documents/csm/csm_web/venv/bin/activate
68
79
```
69
-
* This likely happens because you moved your folder after creating your virtualenv. Removing
70
-
and recreating your virtualenv should fix it.
80
+
81
+
- This likely happens because you moved your folder after creating your virtualenv. Removing
82
+
and recreating your virtualenv should fix it.
71
83
72
84
### How do I access the `/admin` page?
73
-
* The `./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.
74
-
* If you wish to assign admin permissions to an account that uses OAuth (such as your Berkeley email), run the following commands in the Django shell (accessible by running `python3 csm_web/manage.py shell`):
75
-
```
85
+
86
+
- The `./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.
87
+
- If you wish to assign admin permissions to an account that uses OAuth (such as your Berkeley email), run the following commands in the Django shell (accessible by running `python3 csm_web/manage.py shell`):
88
+
89
+
```py
76
90
from scheduler.models import*
77
91
# replace "my_username" with the prefix of your Berkeley email, as in "my_username@berkeley.edu"
78
92
user = User.objects.get(username="my_username")
@@ -82,25 +96,31 @@ user.save()
82
96
```
83
97
84
98
### Miscellaneous
99
+
85
100
#### OSX: error on running `pip`
101
+
86
102
Try replacing `pip` with `pip3` instead.
87
103
88
104
#### OAuth errors when trying to sign in locally
105
+
89
106
```
90
107
Error 401: invalid_client
91
108
The OAuth client was not found.
92
109
```
110
+
93
111
OAuth secrets are sourced from the heroku repository: you'll need to log in to heroku, add the
94
112
appropriate remote, rerun `setup.sh`, and then reactivate your virtualenv.
95
113
96
114
### On `runserver`, long stack trace ending with this:
115
+
97
116
```
98
-
django.db.utils.OperationalError: could not connect to server: Connection refused
99
-
Is the server running on host "localhost" (::1) and accepting
100
-
TCP/IP connections on port 5432?
101
-
could not connect to server: Connection refused
102
-
Is the server running on host "localhost" (127.0.0.1) and accepting
103
-
TCP/IP connections on port 5432?
117
+
django.db.utils.OperationalError: could not connect to server: Connection refused
118
+
Is the server running on host "localhost" (::1) and accepting
119
+
TCP/IP connections on port 5432?
120
+
could not connect to server: Connection refused
121
+
Is the server running on host "localhost" (127.0.0.1) and accepting
122
+
TCP/IP connections on port 5432?
104
123
```
124
+
105
125
Your postgres server is likely not running. On a mac (which is the only platform we've done local
106
126
testing on), run `brew services start postgres` before invoking `runserver` again.
0 commit comments