https://github.com/webkom/admissions
👥 Admission system for Abakus
https://github.com/webkom/admissions
django react styled-components
Last synced: 11 months ago
JSON representation
👥 Admission system for Abakus
- Host: GitHub
- URL: https://github.com/webkom/admissions
- Owner: webkom
- License: mit
- Created: 2018-03-12T18:49:23.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2025-04-30T12:52:02.000Z (about 1 year ago)
- Last Synced: 2025-04-30T13:48:42.729Z (about 1 year ago)
- Topics: django, react, styled-components
- Language: TypeScript
- Homepage: https://opptak.abakus.no
- Size: 5.98 MB
- Stars: 6
- Watchers: 13
- Forks: 1
- Open Issues: 28
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# admissions
Recruitment for [Abakus](https://abakus.no/).
**Table of contents**
- [Environments](#environments)
- [Local development](#local-development)
- [Creating admissions](#creating-admissions)
- [Permissions](#permissions)
- [Run tests](#run-tests)
- [Code style](#code-style)
Â
## Environments
### Production
[opptak.abakus.no](https://opptak.abakus.no/)
OAuth through [abakus.no](https://abakus.no/)
### Staging
[opptak-staging.abakus.no](https://opptak-staging.abakus.no/)
OAuth through [abakus.no](https://abakus.no/)
Â
## Local development
### Prerequisites
To run this project, you need
1. python 3.12
2. Docker OR a `postgresql` database
3. [poetry](https://python-poetry.org/) ([installation guide](https://python-poetry.org/docs/#installation))
4. Node and yarn
### Running the project
> When working in development you want to have LEGO running (both frontend and backend). This allows you to create an OAuth2 application from the settings menu in the webapp.
To do this, you need a total of **4 terminals** (or shells if you like).
### Terminal 1
Run LEGO by following the README [here](https://github.com/webkom/lego#readme).
### Terminal 2
Run LEGO-WEBAPP by following the README [here](https://github.com/webkom/lego-webapp#readme).
### Terminal 3
Install the projects dependencies with
```sh
$ poetry install
```
This command will also create a virtual environment in which the dependencies are installed, if one has not already been created and activated.
Then, run the following command
```sh
$ make dev_settings
```
The [`docker-compose.yml`](./docker-compose.yml) file provides a `postgresql` database. This uses a different port than LEGO, so you can run it in parallel as follows.
```sh
$ docker-compose up -d
```
#### Secrets
The `.env` file with secret keys is not included, but an [`example.env`](./admissions/settings/example.env) file has been provided in `./admissions/settings`, so that you can simply rename the file and fill in the values.
`example.env` is setup to connect to an Oauth2 application already configured in LEGO, so if you don't need anything special you are good to go with that one.
If you want to configure another one, go to the OAuth2 tab in the user settings [menu](http://localhost:3000/users/me/settings/oauth2) in the running dev version of lego-webapp. Open or create an application, and enter the values you find into your .env file. If you are creating a new OAuth2 application, enter `http://127.0.0.1:5000/complete/lego/` as the redirect url.
```sh
# Create a copy of the example env file (run from the root of the project)
$ cp admissions/settings/example.env admissions/settings/.env
# Edit the file and change the KEY and SECRET
AUTH_LEGO_KEY="Client ID from OAuth2"
AUTH_LEGO_SECRET="Client Secret from OAuth2"
AUTH_LEGO_API_URL="http://localhost:8000/"
```
After creating and configuring your ./admissions/settings/.env file you are ready to migrate the database and run the server.
```sh
# Migrate the database migrations
$ poetry run python manage.py migrate
# Run the Django server
$ poetry run python manage.py runserver
```
> If coding over long periods of time, or you want to flush the database, run `poetry run python manage.py flush` to flush it, and run the server again with `poetry run python manage.py runserver`.
### Terminal 4
In the last terminal you are ready to start the frontend. The frontend requires `Node`. You simply need to install the requirements and run the dev-server as follows.
```sh
# Install dependencies
$ yarn
# Start the dev-server
$ yarn dev
```
> Finally, you can go to [127.0.0.1:5000](http://127.0.0.1:5000/) and view the admissions page.
**NB: The project has to be accessed through 127.0.0.1, and NOT localhost.** This is because accessing both LEGO and admissions from the same hostname creates a conflict some session storage, so the login will not work.
To create an admission, first, open [127.0.0.1:5000](http://127.0.0.1:5000/) and click the "Logg inn" button at the bottom of the page to authorize as a user with [permission to create admissions](#permissions). Then, click "Administrer opptak" and create an admission. Phew, now you are ready to start developing!
Â
## Creating admissions
### GUI
The simplest way to create an admission is through the GUI.
1. Navigate to [127.0.0.1:5000](http://127.0.0.1:5000/)
2. Log in as a user with permission to create admissions.
3. Click "Administrer opptak" at the bottom of the screen
4. Success
### Shell
Currently when running
```sh
# Create a custom admission for development
$ poetry run python manage.py create_admission
```
you create an admission connected to all groups, if they exist (they are generated the first time you log in). To connect it to a group, you can either do it through the GUI, or create it in the shell.
Note that when creating groups in the shell, you must import the Group model manually, as otherwise it will use the Django Group model instead of our own.
```python
$ poetry run python manage.py shell_plus
> from admissions.admissions.models import Group
> new_group = Group.objects.create(name="GroupA")
> admission = Admission.objects.get(slug="opptak")
> admission.groups.add(new_group)
```
Â
## Permissions
The project gives permissions based on group memberships imported from LEGO.
| Model | Action | Requirement |
| :---------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------- |
| Admission | CREATE | Either (1) any member of Webkom, (2) leader of Abakus OR (3) leader of RevyStyret.
(1,2,3) `user.is_staff` |
| Admission | EDIT | Either (1) member of Webkom OR (2) creator of admission.
(1) `user.is_member_of_webkom`, (2) `admission.created_by`. |
| All applications | VIEW & DELETE | Member of a group in `admission.admin_groups` |
| Applications to a group | VIEW & DELETE | Member of a group in `admission.groups` WITH role LEADER or RERUITING |
| Group | EDIT | Member of a group in `admission.groups` WITH role LEADER or RERUITING |
Â
## Run tests
Run django tests using tox. Note that we point at the admissions database running at :5433 if we are running lego and admissions in parallel
```bash
$ DATABASE_PORT=5433 poetry run tox -e tests
```
Â
## Code style
This codebase uses the PEP 8 code style. We enforce this with isort, black & flake8.
In addition to the standards outlined in PEP 8, we have a few guidelines
(see `setup.cfg` for more info):
Format the code with black & isort
```bash
$ make fixme
```
To check if it is formatted properly, run:
```bash
$ DATABASE_PORT=5433 poetry run tox -e isort -e flake8 -e black
```