Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/economy/templates/emails/expense_approved_email.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
Hi,

Your expense {{ expense.pk }} for {{ expense.camp.title }} has been approved. The amount is DKK {{ expense.amount }} and description of the expense is:
Your expense {{ expense.pk }} for {{ expense.camp.title }} has been approved.

The amount is DKK {{ expense.amount }} and description of the expense is:

{{ expense.description }}

{% if not expense.paid_by_bornhack %}The money will be transferred to your bank account with the next batch of reimbursements.{% else %}As this expense was paid for by BornHack no further action will be taken.{% endif %}
{% if expense.paid_by_bornhack %}
As this expense was paid for by BornHack no further action will be taken.
{% else %}
IMPORTANT: Before we can transfer the money to your bank account, you need to create a reimbursement.

Please visit https://bornhack.dk/{{ expense.camp.slug }}/economy/reimbursements/create/

The money will be transferred to your bank account with the next batch, after creating the reimbursement.
{% endif %}

Have a nice day!

Expand Down
6 changes: 6 additions & 0 deletions src/profiles/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from .signal_handlers import create_profile
from .signal_handlers import profile_pre_save
from .signal_handlers import set_session_on_login
from .signal_handlers import reimbursement_msg_on_login

logger = logging.getLogger(f"bornhack.{__name__}")

Expand All @@ -36,3 +37,8 @@ def ready(self) -> None:
sender=User,
dispatch_uid="profile_set_session_on_login_signal",
)
user_logged_in.connect(
reimbursement_msg_on_login,
sender=User,
dispatch_uid="reimbursement_msg_on_login_signal",
)
15 changes: 15 additions & 0 deletions src/profiles/signal_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import logging

from django.contrib import messages

from events.handler import handle_team_event

logger = logging.getLogger(f"bornhack.{__name__}")
Expand Down Expand Up @@ -76,3 +78,16 @@ def nickserv_username_changed(instance, original) -> None:
def set_session_on_login(sender, request, user, **kwargs) -> None:
"""Signal handler called on_login to set session["theme"] from the user profile."""
request.session["theme"] = request.user.profile.theme

def reimbursement_msg_on_login(sender, request, user, **kwargs) -> None:
"""
Add message when user has approved expenses without matching reimbursement.
"""
approved_expenses = user.expenses.all().filter(approved=True, reimbursement=None)

if approved_expenses.exists():
messages.info(
request,
f"You have {approved_expenses.count()} expenses with missing reimbursement"
)

Loading