Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ideal topups #65

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
34 changes: 25 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@ Copy `sample.env` to `.env` and make sure the database options are correct. By d

```bash
docker compose up -d
uv run --env-file .env ./manage.py migrate
```

In development, create an admin superuser

```bash
uv run --env-file .env ./manage.py createsuperuser
uv run --env-file .env manage.py migrate
```

Then depending on whether you want to use a local version of koala, you need to do some additional setup:
Expand Down Expand Up @@ -78,12 +72,34 @@ Then depending on whether you want to use a local version of koala, you need to

Copy the application id and secret into the `.env` file and make sure you update the oauth urls to point to koala.dev.svsticky.nl.

Then complete the `.env` file by filling out the following values:

```env
USER_URL=https://koala.dev.svsticky.nl

ALLOWED_HOSTS=localhost
OIDC_RP_CLIENT_ID=<secret from koala>
OIDC_RP_CLIENT_SECRET=<secret from koala>

OIDC_OP_AUTHORIZATION_ENDPOINT=https://koala.dev.svsticky.nl/api/oauth/authorize
OIDC_OP_TOKEN_ENDPOINT=https://koala.dev.svsticky.nl/api/oauth/token
OIDC_OP_USER_ENDPOINT=https://koala.dev.svsticky.nl/oauth/userinfo
OIDC_OP_JWKS_ENDPOINT=https://koala.dev.svsticky.nl/oauth/discovery/keys
OIDC_OP_LOGOUT_ENDPOINT=https://koala.dev.svsticky.nl/signout
```

Lastly, make sure you have the mollie api key if you want to work with the iDeal payment system. If you leave it blank, mongoose will still work, except for submitting the top up form. For development you want to use a test token, which can be found in the IT Crowd bitwarden.

```env
MOLLIE_API_KEY=test_<secret from bitwarden>
```

## Running

``` bash
# Database
# Start the database, if it wasn't already running
docker compose up -d

# Server
uv run --env-file .env ./manage.py runserver
uv run --env-file .env manage.py runserver
```
5 changes: 5 additions & 0 deletions admin_board_view/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django import forms


class TopUpForm(forms.Form):
amount = forms.DecimalField(min_value=0, decimal_places=2, required=True)
30 changes: 26 additions & 4 deletions admin_board_view/templates/user_home.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@
{% load static %}
{% block body %}
<main class="container mt-3">
{% if transaction %}
{% if transaction.status == PaymentStatus.PAID %}
<div class="alert alert-success">
The transaction was successful and your balance is updated!
</div>
{% elif transaction.status == PaymentStatus.CANCELLED %}
<div class="alert alert-danger">
The transaction failed! If you believe this is a mistake, please contact the board.
</div>
{% else %}
<div class="alert alert-info">
We are processing your payment. Once it succeed, your balance will be updated!
</div>
{% endif %}
{% endif %}
<h1>Welcome {{ user_info.name }}</h1>
<h5 class="mb-2">
Current balance: <b>{{ user_info.euro_balance }}</b>
Expand Down Expand Up @@ -51,16 +66,23 @@ <h5 class="card-header">Top ups</h5>
</tr>
</thead>
<tbody>
{% for top_up in top_ups.object_list %}
{% for date, price, type in top_ups %}
<tr>
<td>{{ top_up.date }}</td>
<td>€{{ top_up.transaction_sum }}</td>
<td>{% if top_up.type == 1 %}Pin{% elif top_up.type == 2 %}Credit card{% elif top_up.type == 3 %}Mollie{% endif %}</td>
<td>{{ date }}</td>
<td>€{{ price }}</td>
<td>{{ type }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% include "pagination_footer.html" with page=top_ups page_name='top_ups' %}
<hr />
<form action="/api/topup" method="post">
{% csrf_token %}
<h5>Top up balance</h5>
{{ form }}
<input type="submit" />
</form>
</div>
</div>
</div>
Expand Down
Loading