Compare commits

...

6 commits

6 changed files with 56 additions and 31 deletions

View file

@ -206,7 +206,7 @@ MAIL_DATA = {
"REPLYTO": "cof@ens.fr", "REPLYTO": "cof@ens.fr",
}, },
"rappels": {"FROM": "Le BdA <bda@ens.fr>", "REPLYTO": "Le BdA <bda@ens.fr>"}, "rappels": {"FROM": "Le BdA <bda@ens.fr>", "REPLYTO": "Le BdA <bda@ens.fr>"},
"rappel_negatif": { "kfet": {
"FROM": "La K-Fêt <chefs-k-fet@ens.fr>", "FROM": "La K-Fêt <chefs-k-fet@ens.fr>",
"REPLYTO": "La K-Fêt <chefs-k-fet@ens.fr>", "REPLYTO": "La K-Fêt <chefs-k-fet@ens.fr>",
}, },

View file

@ -2,6 +2,7 @@ import re
from django.conf import settings from django.conf import settings
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.contrib.sites.models import Site
from django.core.mail import EmailMessage from django.core.mail import EmailMessage
from django.core.validators import RegexValidator from django.core.validators import RegexValidator
from django.db import models, transaction from django.db import models, transaction
@ -269,6 +270,32 @@ class Account(models.Model):
def __init__(self, trigramme): def __init__(self, trigramme):
self.trigramme = trigramme self.trigramme = trigramme
def send_creation_email(self):
"""
Envoie un mail à la création du trigramme.
"""
mail_data = settings.MAIL_DATA["kfet"]
email = EmailMessage(
subject="Création d'un trigramme",
body=loader.render_to_string(
"kfet/mails/creation_trigramme.txt",
context={
"account": self,
"site": Site.objects.get_current(),
"url_read": reverse("kfet.account.read", args=(self.trigramme)),
"url_update": reverse("kfet.account.update", args=(self.trigramme)),
"url_delete": reverse("kfet.account.delete", args=(self.trigramme))
},
),
from_email=mail_data["FROM"],
to=[self.email],
reply_to=[mail_data["REPLYTO"]],
)
# On envoie le mail
email.send()
def get_deleted_account(): def get_deleted_account():
return Account.objects.get(trigramme=KFET_DELETED_TRIGRAMME) return Account.objects.get(trigramme=KFET_DELETED_TRIGRAMME)
@ -298,7 +325,7 @@ class AccountNegative(models.Model):
""" """
Envoie un mail de rappel signalant que la personne est en négatif. Envoie un mail de rappel signalant que la personne est en négatif.
""" """
mail_data = settings.MAIL_DATA["rappel_negatif"] mail_data = settings.MAIL_DATA["kfet"]
email = EmailMessage( email = EmailMessage(
subject="Compte K-Psul négatif", subject="Compte K-Psul négatif",
@ -321,7 +348,6 @@ class AccountNegative(models.Model):
# On enregistre le fait que l'envoi a bien eu lieu # On enregistre le fait que l'envoi a bien eu lieu
self.last_rappel = timezone.now() self.last_rappel = timezone.now()
self.save() self.save()
return
class CheckoutQuerySet(models.QuerySet): class CheckoutQuerySet(models.QuerySet):

View file

@ -78,7 +78,7 @@ class KfetWebsocket {
listen() { listen() {
var that = this; var that = this;
this.socket = new ReconnectingWebSocket(this.url); this.socket = new ReconnectingWebSocket(this.url, [], { minReconnectionDelay: 100 });
this.socket.onmessage = function (e) { this.socket.onmessage = function (e) {
var data = $.extend({}, that.default_msg, JSON.parse(e.data)); var data = $.extend({}, that.default_msg, JSON.parse(e.data));

View file

@ -0,0 +1,12 @@
Salut {{ account.name }},
Ton compte K-Fêt a bien été créé le {{ account.created_at }} avec le trigramme {{ account.trigramme }}.
Tu peux désormais :
- Accéder à ton historique personnel des consommations : https://{{ site }}{{ url_read }}
- Modifier tes informations : https://{{ site }}{{ url_update }}
- Supprimer ton compte : https://{{ site }}{{ url_delete }}
En espérant te revoir bientôt,
--
L'équipe K-Fêt

View file

@ -243,6 +243,7 @@ def account_create(request):
account_form = AccountNoTriForm(request.POST, instance=account) account_form = AccountNoTriForm(request.POST, instance=account)
account_form.save() account_form.save()
messages.success(request, "Compte créé : %s" % account.trigramme) messages.success(request, "Compte créé : %s" % account.trigramme)
account.send_creation_email()
return redirect("kfet.account.create") return redirect("kfet.account.create")
except Account.UserHasAccount as e: except Account.UserHasAccount as e:
messages.error( messages.error(

View file

@ -1,29 +1,12 @@
{ pkgs ? import <nixpkgs> { }, ... }: {
pkgs ? import <nixpkgs> { },
...
}:
let let
python = pkgs.python38; python = pkgs.python39;
django-types = python.pkgs.buildPythonPackage rec {
pname = "django-types";
version = "0.17.0";
format = "pyproject";
src = pkgs.fetchPypi {
inherit pname version;
hash = "sha256-wcQqt4h2xXxyg0LVqwYHJas3H8jcg7uFuuC+BoRqrXA=";
};
nativeBuildInputs = with python.pkgs; [ poetry-core ];
# setup.cfg tries to pull in nonexistent LICENSE.txt file
# postPatch = "rm setup.cfg";
# propagatedBuildInputs = [ django typing-extensions ];
};
in in
pkgs.mkShell { pkgs.mkShell {
shellHook = '' shellHook = ''
export DJANGO_SETTINGS_MODULE=gestioasso.settings.local export DJANGO_SETTINGS_MODULE=gestioasso.settings.local
@ -34,11 +17,14 @@ pkgs.mkShell {
pip install -r requirements-devel.txt | grep -v 'Requirement already satisfied:' pip install -r requirements-devel.txt | grep -v 'Requirement already satisfied:'
''; '';
packages = [ python django-types ] ++ (with python.pkgs; [ packages =
pip [ python ]
virtualenv ++ (with python.pkgs; [
python-ldap django-types
]); pip
virtualenv
python-ldap
]);
allowSubstitutes = false; allowSubstitutes = false;
} }