Merge branch 'k-fet' into qwann/k-fet/home

This commit is contained in:
Qwann 2017-03-05 19:21:20 +01:00
commit f52aba8ca6
15 changed files with 511 additions and 557 deletions

View file

@ -18,6 +18,7 @@ from django.db.models import F
from django.core.cache import cache
from datetime import date, timedelta
import re
import hashlib
def choices_length(choices):
return reduce(lambda m, choice: max(m, len(choice[0])), choices, 0)
@ -154,6 +155,7 @@ class Account(models.Model):
# - Enregistre User, CofProfile à partir de "data"
# - Enregistre Account
def save(self, data = {}, *args, **kwargs):
if self.pk and data:
# Account update
@ -200,6 +202,11 @@ class Account(models.Model):
self.cofprofile = cof
super(Account, self).save(*args, **kwargs)
def change_pwd(self, pwd):
pwd_sha256 = hashlib.sha256(pwd.encode('utf-8'))\
.hexdigest()
self.password = pwd_sha256
# Surcharge de delete
# Pas de suppression possible
# Cas à régler plus tard
@ -561,7 +568,7 @@ class Operation(models.Model):
templates = {
self.PURCHASE: "{nb} {article.name} ({amount}€)",
self.DEPOSIT: "charge ({amount})",
self.WITHDRAW: "retrait ({amount})",
self.WITHDRAW: "retrait ({amount})",
self.INITIAL: "initial ({amount})",
}
return templates[self.type].format(nb=self.article_nb,