mirror of https://gitlab.crans.org/bde/nk20
Prevent also club owners when the note balance is negative
This commit is contained in:
parent
1bbe7df797
commit
0c753c3288
|
@ -173,6 +173,21 @@ class NoteClub(Note):
|
||||||
def pretty(self):
|
def pretty(self):
|
||||||
return _("Note of %(club)s club") % {'club': str(self.club)}
|
return _("Note of %(club)s club") % {'club': str(self.club)}
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
if self.pk and self.balance < 0:
|
||||||
|
old_note = NoteClub.objects.get(pk=self.pk)
|
||||||
|
if old_note.balance >= 0:
|
||||||
|
# Passage en négatif
|
||||||
|
self.last_negative = timezone.now()
|
||||||
|
self.send_mail_negative_balance()
|
||||||
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
def send_mail_negative_balance(self):
|
||||||
|
plain_text = render_to_string("note/mails/negative_balance.txt", dict(note=self))
|
||||||
|
html = render_to_string("note/mails/negative_balance.html", dict(note=self))
|
||||||
|
self.user.email_user("[Note Kfet] Passage en négatif (club {})"
|
||||||
|
.format(self.club.name), plain_text, html_message=html)
|
||||||
|
|
||||||
|
|
||||||
class NoteSpecial(Note):
|
class NoteSpecial(Note):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<p>
|
<p>
|
||||||
Bonjour {{ note.user.first_name }} {{ note.user.last_name }},
|
Bonjour {{ note }},
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
{% load getenv %}
|
{% load getenv %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
Bonjour {{ note.user.first_name }} {{ note.user.last_name }},
|
Bonjour {{ note }},
|
||||||
|
|
||||||
Ce mail t'a été envoyé parce que le solde de ta Note Kfet
|
Ce mail t'a été envoyé parce que le solde de ta Note Kfet
|
||||||
{{ note }} est négatif !
|
{{ note }} est négatif !
|
||||||
|
|
|
@ -22,10 +22,17 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for note in notes %}
|
{% for note in notes %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ note.user.last_name }}</td>
|
{% if note.user %}
|
||||||
<td>{{ note.user.first_name }}</td>
|
<td>{{ note.user.last_name }}</td>
|
||||||
<td>{{ note.user.username }}</td>
|
<td>{{ note.user.first_name }}</td>
|
||||||
<td>{{ note.user.email }}</td>
|
<td>{{ note.user.username }}</td>
|
||||||
|
<td>{{ note.user.email }}</td>
|
||||||
|
{% else %}
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td>{{ note.club.name }}</td>
|
||||||
|
<td>{{ note.club.email }}</td>
|
||||||
|
{% endif %}
|
||||||
<td>{{ note.balance|pretty_money }}</td>
|
<td>{{ note.balance|pretty_money }}</td>
|
||||||
<td>{{ note.last_negative_duration }}</td>
|
<td>{{ note.last_negative_duration }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
Nom | Prénom | Pseudo | Email | Solde | Durée
|
Nom | Prénom | Pseudo | Email | Solde | Durée
|
||||||
---------------------+------------+-----------------+-----------------------------------+----------+-----------
|
---------------------+------------+-----------------+-----------------------------------+----------+-----------
|
||||||
{% for note in notes %}
|
{% for note in notes %}
|
||||||
{{ note.user.last_name }} | {{ note.user.first_name }} | {{ note.user.username }} | {{ note.user.email }} | {{ note.balance|pretty_money }} | {{ note.last_negative_duration }}
|
{% if note.user %}{{ note.user.last_name }} | {{ note.user.first_name }} | {{ note.user.username }} | {{ note.user.email }} | {{ note.balance|pretty_money }} | {{ note.last_negative_duration }}{% else %} | | {{ note.club.name }} | {{ note.club.email }} | {{ note.balance|pretty_money }} | {{ note.last_negative_duration }}{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
--
|
--
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 4179cad611151d2b66da3fc87cebcb5317779cb2
|
Subproject commit 2b1c05ff98327cfda8ea968376c3b47d6f2aeccb
|
Loading…
Reference in New Issue