Commit 03393ec7 authored by colmoneill's avatar colmoneill

new badge attribution system almost there:

If quizz is successful, checks to see if there is a badge
object in the badges collection that corresponds to the name
set in the quiz json. If yes, it's passed and saved into a
ListField in the User Document.

Almost all good but writes a string of the badge object instead
of a list seperated array
parent c406e8c8
......@@ -200,16 +200,12 @@ class User(db.Document, UserMixin):
password = db.StringField(max_length=255)
confirmed_at = db.DateTimeField()
# badges = db.DictField(default = badges)
badges = db.DictField()
badges = db.ListField(db.DynamicField())
roles = db.ListField(db.ReferenceField(Role))
#badges = db.ListField( db.ReferenceField(Badges))
# dashboard_view_count = db.StringField(max_length=3, default=[0])
meta = {'strict': False}
class ExtendedRegisterForm(RegisterForm):
first_name = StringField('prenom', validators=[DataRequired()])
last_name = StringField('nom', validators=[DataRequired()])
......@@ -330,11 +326,13 @@ def check_quiz(id):
print('award badge ' + badge)
updateUser = User.objects.get(id= C_user)
dbbadge = Badge.objects(name=badge)
dbbadge = dbbadge.to_json()
updateUser.badges = dbbadge
# updateUser.update(push__badges=dbbadge)
# print(updateUser)
success_message = gettext(" Felicitation vous avez le badge : ") + badge +"<i class='material-icons'>sentiment_satisfied</i>"
flash(success_message, 'alert-success')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment