|
|
@ -98,7 +98,6 @@ class Member(User, db.Model): |
|
|
|
email = db.Column(db.Unicode(120), index=True, unique=True) |
|
|
|
password_hash = db.Column(db.String(255)) |
|
|
|
xp = db.Column(db.Integer) |
|
|
|
innovation = db.Column(db.Integer) |
|
|
|
register_date = db.Column(db.Date, default=date.today) |
|
|
|
|
|
|
|
# Avatars # TODO: rendre ça un peu plus propre |
|
|
@ -108,8 +107,7 @@ class Member(User, db.Model): |
|
|
|
|
|
|
|
@property |
|
|
|
def level(self): |
|
|
|
xp = self.xp + 2 * self.innovation |
|
|
|
level = math.asinh(xp / 1000) * (100 / math.asinh(10)) |
|
|
|
level = math.asinh(self.xp / 1000) * (100 / math.asinh(10)) |
|
|
|
return int(level), int(level * 100) % 100 |
|
|
|
|
|
|
|
# Groups and related privileges |
|
|
@ -137,7 +135,6 @@ class Member(User, db.Model): |
|
|
|
self.email = email |
|
|
|
self.set_password(password) |
|
|
|
self.xp = 0 |
|
|
|
self.innovation = 0 |
|
|
|
|
|
|
|
self.bio = "" |
|
|
|
self.signature = "" |
|
|
@ -212,15 +209,12 @@ class Member(User, db.Model): |
|
|
|
# For admins only |
|
|
|
if "xp" in data: |
|
|
|
self.xp = data["xp"] |
|
|
|
if "innovation" in data: |
|
|
|
self.innovation = data["innovation"] |
|
|
|
|
|
|
|
def get_public_data(self): |
|
|
|
"""Returns the public information of the member.""" |
|
|
|
return { |
|
|
|
"name": self.name, |
|
|
|
"xp": self.xp, |
|
|
|
"innovation": self.innovation, |
|
|
|
"register_date": self.register_date, |
|
|
|
"bio": self.bio, |
|
|
|
"signature": self.signature, |
|
|
@ -232,14 +226,7 @@ class Member(User, db.Model): |
|
|
|
Reward xp to a member. If [amount] is negative, the xp total of the |
|
|
|
member will decrease, down to zero. |
|
|
|
""" |
|
|
|
self.xp_points = max(self.xp_points + amount, 0) |
|
|
|
|
|
|
|
def add_innovation(self, amount): |
|
|
|
""" |
|
|
|
Reward innovation points to a member. If [amount] is negative, the |
|
|
|
innovation points total will decrease, down to zero. |
|
|
|
""" |
|
|
|
self.innovation = max(self.innovation + amount, 0) |
|
|
|
self.xp_points = min(max(self.xp_points + amount, 0), 1000000000) |
|
|
|
|
|
|
|
def set_password(self, password): |
|
|
|
""" |
|
|
|