Small modifications

This commit is contained in:
Darks 2019-08-09 23:20:53 +02:00
parent 1d638689c6
commit ff21d89c23
Signed by untrusted user: Darks
GPG Key ID: F61F10FA138E797C
3 changed files with 12 additions and 8 deletions

View File

@ -7,7 +7,7 @@ name = "pypi"
flask = ">=1.0"
flask-wtf = ">=0.14"
flask-login = ">=0.4"
flask-migrate = ">=2.3 "
flask-migrate = ">=2.3"
flask-sqlalchemy = ">=2.3"
flask-script = ">=2.0"
uwsgi = ">=2.0"

View File

@ -206,22 +206,24 @@ class Member(User, db.Model):
def add_trophy(self, t):
"""
Add a trophy to the current user. heck whether the request sender has the right
to do this!
Add a trophy to the current user. Check whether the request sender has
the right to do this!
"""
if type(t) == int:
t = Trophy.get(t)
if type(t) == str:
t = Trophy.query.filter_by(name=name).first()
t = Trophy.query.filter_by(name=t).first()
if t not in self.trophies:
self.trophies.append(t)
db.session.merge(self)
db.session.commit()
# TODO: implement the notification system
# self.notify(f"Vous venez de débloquer le trophée '{name}'")
# self.notify(f"Vous venez de débloquer le trophée '{t.name}'")
def del_trophy(self, t):
"""
Add a trophy to the current user. heck whether the request sender has the right
to do this!
Add a trophy to the current user. Check whether the request sender has
the right to do this!
"""
if type(t) == str:
t = Trophy.query.filter_by(name=name).first()
@ -271,7 +273,8 @@ class Member(User, db.Model):
if age.days > 365.25 * 5:
self.add_trophy("Papy Casio")
if context == "on-profile-update" or context is None:
pass
# TODO: add a better condition (this is for test)
self.add_trophy("Artiste")
def __repr__(self):
return f'<Member: {self.name}>'

View File

@ -25,6 +25,7 @@ def edit_account():
)
db.session.merge(current_user)
db.session.commit()
current_user.update_trophies("on-profile-update")
flash('Modifications effectuées', 'ok')
else:
flash('Erreur lors de la modification', 'error')