account: remove innovation counter, use only xp

This commit is contained in:
Lephe 2019-06-05 16:40:57 -04:00
parent 28897cfa6d
commit 21ebfb7d2a
5 changed files with 30 additions and 24 deletions

View File

@ -51,7 +51,6 @@ class AdminUpdateAccountForm(FlaskForm):
description="L'ancien mot de passe ne pourra pas être récupéré !",
validators=[Optional(), vd.password])
xp = DecimalField('XP', validators=[Optional()])
innovation = DecimalField('Innovation', validators=[Optional()])
birthday = DateField('Anniversaire', validators=[Optional()])
signature = TextAreaField('Signature', validators=[Optional()])
biography = TextAreaField('Présentation', validators=[Optional()])

View File

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

View File

@ -105,7 +105,6 @@ def adm_edit_account(user_id):
bio=form.biography.data,
newsletter=form.newsletter.data,
xp=form.xp.data or None,
innovation=form.innovation.data or None
)
db.session.merge(user)
db.session.commit()

View File

@ -55,13 +55,6 @@
<span class="msgerror">{{ error }}</span>
{% endfor %}
</div>
<div>
{{ form.innovation.label }}
{{ form.innovation(placeholder=user.innovation) }}
{% for error in form.innovation.errors %}
<span class="msgerror">{{ error }}</span>
{% endfor %}
</div>
<h2>À propos</h2>
<div>

View File

@ -0,0 +1,28 @@
"""empty message
Revision ID: 0fffe230b8ba
Revises: 53f5ab9da859
Create Date: 2019-06-05 16:38:01.464333
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '0fffe230b8ba'
down_revision = '53f5ab9da859'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('member', 'innovation')
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('member', sa.Column('innovation', sa.INTEGER(), autoincrement=False, nullable=True))
# ### end Alembic commands ###