trophies: add descriptions
DATABASE UPDATE: run [flask db upgrade], then use the [create-trophies] command of the master script to recreate trophies.
This commit is contained in:
parent
1622b3c083
commit
c4bfef4765
|
@ -1,120 +1,154 @@
|
|||
# This is a list of trophies. For each trophies, the following keys may be set:
|
||||
# name Trophy name as displayed on the site.
|
||||
# is_title If True, the trophy can be worn as a title next to the avatar.
|
||||
# name Trophy name as displayed on the site.
|
||||
# is_title If True, the trophy can be worn as a title next to the avatar.
|
||||
# description Detailed description to be shown on profile page.
|
||||
|
||||
# Manually awarded
|
||||
-
|
||||
name: Membre de CreativeCalc
|
||||
is_title: True
|
||||
description: Membre de l'association qui gère Planète Casio !
|
||||
-
|
||||
name: Membre d'honneur
|
||||
is_title: True
|
||||
description: Gloire, honneur et déférence sont dûs.
|
||||
-
|
||||
name: Grand Manitou
|
||||
is_title: True
|
||||
description: Le seul. L'unique. Le GRAND MANITOU.
|
||||
-
|
||||
name: Gourou
|
||||
is_title: True
|
||||
description: Possède des trophées obscurs.
|
||||
-
|
||||
name: Grand Maître des traits d'esprit
|
||||
is_title: True
|
||||
description: Inégalé pour l'heure.
|
||||
|
||||
# Number of posts of any kind
|
||||
-
|
||||
name: Premiers mots
|
||||
is_title: False
|
||||
description: Écrire 20 messages.
|
||||
-
|
||||
name: Beau parleur
|
||||
is_title: False
|
||||
description: Écrire 500 messages.
|
||||
-
|
||||
name: Plume infaillible
|
||||
is_title: False
|
||||
description: Écrire 1500 messages.
|
||||
-
|
||||
name: Romancier émérite
|
||||
is_title: True
|
||||
description: Écrire 5000 messages !
|
||||
|
||||
# Number of posted tutorials
|
||||
-
|
||||
name: Pédagogue
|
||||
is_title: False
|
||||
description: Élaborer 5 tutoriels.
|
||||
-
|
||||
name: Encyclopédie vivante
|
||||
is_title: False
|
||||
description: Élaborer 10 tutoriels.
|
||||
-
|
||||
name: Guerrier du savoir
|
||||
is_title: True
|
||||
description: Élaborer 25 tutoriels !
|
||||
|
||||
# Account age (awarded on login only)
|
||||
-
|
||||
name: Initié
|
||||
is_title: False
|
||||
description: Être membre pendant 1 mois.
|
||||
-
|
||||
name: Aficionado
|
||||
is_title: False
|
||||
description: Être membre pendant 1 an.
|
||||
-
|
||||
name: Veni, vidi, casii
|
||||
is_title: False
|
||||
description: Être membre pendant 2 ans.
|
||||
-
|
||||
name: Papy Casio
|
||||
is_title: True
|
||||
description: Être membre pendant 5 ans.
|
||||
-
|
||||
name: Vétéran mythique
|
||||
is_title: True
|
||||
description: Être membre pendant 10 ans !
|
||||
|
||||
# Number of "good" programs
|
||||
-
|
||||
name: Programmeur du dimanche
|
||||
is_title: False
|
||||
description: Publier 5 prorammes.
|
||||
-
|
||||
name: Codeur invétéré
|
||||
is_title: False
|
||||
description: Publier 10 programmes.
|
||||
-
|
||||
name: Je code donc je suis
|
||||
is_title: True
|
||||
description: Publier 20 programmes !
|
||||
|
||||
# Number of posted tests
|
||||
-
|
||||
name: Testeur
|
||||
is_title: False
|
||||
description: Partager 5 tests.
|
||||
-
|
||||
name: Grand joueur
|
||||
is_title: False
|
||||
description: Partager 25 tests.
|
||||
-
|
||||
name: Hard tester
|
||||
is_title: True
|
||||
description: Partager 100 tests !
|
||||
|
||||
# Number of event participations
|
||||
-
|
||||
name: Participant
|
||||
is_title: False
|
||||
description: Participer à un événement du site.
|
||||
-
|
||||
name: Concourant encore
|
||||
is_title: False
|
||||
description: Participer à 5 événements du site.
|
||||
-
|
||||
name: Concurrent de l'extrême
|
||||
is_title: True
|
||||
description: Participer à 15 événements du site !
|
||||
|
||||
# Number of posted art
|
||||
-
|
||||
name: Dessinateur en herbe
|
||||
is_title: False
|
||||
description: Publier 5 assets graphiques.
|
||||
-
|
||||
name: Open pixel
|
||||
is_title: False
|
||||
description: Publier 30 assets graphiques.
|
||||
-
|
||||
name: Roi du pixel
|
||||
is_title: True
|
||||
description: Publier 100 assets graphiques !
|
||||
|
||||
# Miscellaneous automatically awarded
|
||||
-
|
||||
name: Actif
|
||||
is_title: False
|
||||
description: Être présent 30 jours de suite.
|
||||
-
|
||||
name: Artiste
|
||||
is_title: False
|
||||
description: Modifier son avatar.
|
||||
-
|
||||
name: Maître du code
|
||||
is_title: True
|
||||
description: Être décoré 5 fois du label de qualité !
|
||||
-
|
||||
name: Bourreau des cœurs
|
||||
is_title: True
|
||||
description: Foudroyer les cœurs à 5 reprises !
|
||||
|
|
|
@ -15,12 +15,15 @@ class Trophy(db.Model):
|
|||
|
||||
# Trophy name (in French)
|
||||
name = db.Column(db.Unicode(64), index=True)
|
||||
# Description
|
||||
description = db.Column(db.UnicodeText, index=True)
|
||||
|
||||
owners = db.relationship('Member', secondary=lambda: TrophyMember,
|
||||
back_populates='trophies')
|
||||
|
||||
def __init__(self, name):
|
||||
def __init__(self, name, description):
|
||||
self.name = name
|
||||
self.description = description
|
||||
|
||||
def __repr__(self):
|
||||
return f'<Trophy: {self.name}>'
|
||||
|
@ -33,8 +36,9 @@ class Title(Trophy):
|
|||
id = db.Column(db.Integer, db.ForeignKey('trophy.id'), primary_key=True)
|
||||
css = db.Column(db.UnicodeText)
|
||||
|
||||
def __init__(self, name, css=""):
|
||||
def __init__(self, name, description, css=""):
|
||||
self.name = name
|
||||
self.description = description
|
||||
self.css = css
|
||||
|
||||
def __repr__(self):
|
||||
|
|
|
@ -340,7 +340,7 @@ class Member(User):
|
|||
|
||||
if context in ["new-post", "new-program", "new-tutorial", "new-test",
|
||||
None]:
|
||||
# Cannot use ORM tools because it adds circular import issues
|
||||
# FIXME: Use ORM tools with careful, non-circular imports
|
||||
post_count = db.session.execute(f"""SELECT COUNT(*) FROM post
|
||||
INNER JOIN member ON member.id = post.author_id
|
||||
WHERE member.id = {self.id}""").first()[0]
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
<img src="{{ url_for('static', filename='images/fa_124.png') }}">
|
||||
<div>
|
||||
<em>{{ t.name }}</em>
|
||||
<span>Avoir posté 50 messages sur le forum</span>
|
||||
<span>{{ t.description }}</span>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
|
|
@ -171,10 +171,12 @@ def create_trophies():
|
|||
tr = yaml.safe_load(fp.read())
|
||||
|
||||
for t in tr:
|
||||
description = t.get("description", "")
|
||||
|
||||
if t["is_title"]:
|
||||
trophy = Title(t["name"], t.get("css", ""))
|
||||
trophy = Title(t["name"], description, t.get("css", ""))
|
||||
else:
|
||||
trophy = Trophy(t["name"])
|
||||
trophy = Trophy(t["name"], description)
|
||||
db.session.add(trophy)
|
||||
db.session.commit()
|
||||
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
"""add a description to trophies
|
||||
|
||||
Revision ID: b659d4c2a5d1
|
||||
Revises: d1b465f88d3b
|
||||
Create Date: 2020-07-19 22:06:55.789405
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'b659d4c2a5d1'
|
||||
down_revision = 'd1b465f88d3b'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('trophy', sa.Column('description', sa.UnicodeText(), nullable=True))
|
||||
op.create_index(op.f('ix_trophy_description'), 'trophy', ['description'], unique=False)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f('ix_trophy_description'), table_name='trophy')
|
||||
op.drop_column('trophy', 'description')
|
||||
# ### end Alembic commands ###
|
Loading…
Reference in New Issue