ソースを参照

Small modifications

master
Darks 2ヶ月前
コミット
ff21d89c23
署名者: Darks <l.gatin@neuf.fr> GPGキーID: F61F10FA138E797C
3個のファイルの変更12行の追加8行の削除
  1. 1
    1
      Pipfile
  2. 10
    7
      app/models/users.py
  3. 1
    0
      app/routes/account/account.py

+ 1
- 1
Pipfile ファイルの表示

@@ -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"

+ 10
- 7
app/models/users.py ファイルの表示

@@ -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}>'

+ 1
- 0
app/routes/account/account.py ファイルの表示

@@ -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')

読み込み中…
キャンセル
保存