Commit 8060b9a2 authored by erreur401's avatar erreur401

merge

parent a5bdebde
......@@ -74,16 +74,7 @@ class Role(db.Document, RoleMixin):
description = db.StringField(max_length=255)
# class Badges(db.Document):
# badge = db.StringField()
# lvl = db.StringField()
# badges_default =[
# {'cnc': '0'},
# {'laser': '0'},
# {'electronique': '0'},
# {'impression3d':'0'},
# {'maker':'0'}
# ]
2
class User(db.Document, UserMixin):
active = db.BooleanField(default=True)
first_name = db.StringField(max_length=255)
......@@ -94,7 +85,6 @@ class User(db.Document, UserMixin):
# badges = db.DictField(default=[('cnc', 0),('laser', 0),('electronique', 0),('cad', 0),('impression3d', 0), ('maker', 0) ] )
roles = db.ListField( db.ReferenceField(Role), default=[])
badges = db.ListField(default=[{'name':'cnc', 'lvl': 0},{'name':'laser', 'lvl': 0},{'name':'electronique', 'lvl': 0},{'name':'cad', 'lvl': 0},{'name':'impression3d', 'lvl': 0},{'name':'maker', 'lvl': 0}])
# badges = db.ListField( db.embed(Badges))
dashboard_view_count = db.StringField(max_length=3)
......@@ -114,7 +104,13 @@ security = Security(app, user_datastore, register_form=ExtendedRegisterForm)
def index():
eventbrite_json = ur.urlopen(eventbrite_url_requete)
events = json.loads(eventbrite_json.read().decode())
return render_template("home.html" ,events=events)
articles = (p for p in pages if 'published' in p.meta)
print(articles)
# Show the 10 most recent articles, most recent first.
latest = sorted(articles, reverse=True,
key=lambda p: p.meta['published'])
return render_template("home.html" ,events=events ,articles=latest[:4])
@app.route("/learn")
def learn():
......@@ -161,7 +157,7 @@ def check_quiz(id):
ordering = json.loads(request.form['ord'])
quiz = copy.deepcopy(quizzes[id])
badge = quiz['badge']
print(badge)
# print(badge)
badge =str(badge)
# print(request.form)
quiz['questions'] = sorted(quiz['questions'], key=lambda q: ordering.index(quiz['questions'].index(q)))
......@@ -190,7 +186,7 @@ def check_quiz(id):
print('award badge ' + badge)
#bdd.user.update({"_id": ObjectId(user), "badges.name": badge}, {"$set": {"badges.$.lvl": 1}}, multi=True)
# .objects(id=post.id).update(title='Example Post')
update_Query = str('"set__badges__' + badge + '__lvl = 10"')
update_Query = str('set__badges__' + badge + '__lvl = 10')
print(update_Query)
User.objects(id = C_user).update(update_Query ,True)#set__badges__laser__lvl = 22 , upsert=True) #{'badge.lvl' : 1 }, upsert = True )
......@@ -229,7 +225,7 @@ def dashboard():
print('user: ' + C_user)
db_user = User.objects.get(id=C_user).update(inc__dashboard_view_count=1, upsert=True)
message = 'Welcome to your dashboard ' + current_user.get_id()
flash(message)
flash(message , "alert-info")
return render_template('dashboard.html', user=C_user)
......
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