...
 
......@@ -135,15 +135,15 @@ class Events(db.Document):
eventbrite_id = db.StringField(required=True, unique=True)
human_readable_name_of_event = db.StringField()
# class Badge(db.Document): # UserMixin ? RoleMixin ?
# # _id = db.ObjectIdField(default = name)
# name = db.StringField(max_length=60)
# #_id = db.ObjectIdField(default = name)
# description = db.StringField()
# default_level = db.StringField(default=1)
# icon = db.FileField(required=False)
# color_hex = db.StringField()
# # user = db.ReferenceField(User, required=False)
class Badge(db.Document): # UserMixin ? RoleMixin ?
# _id = db.ObjectIdField(default = name)
name = db.StringField(max_length=60)
#_id = db.ObjectIdField(default = name)
description = db.StringField()
default_level = db.StringField(default=1)
icon = db.FileField(required=False)
color_hex = db.StringField()
# user = db.ReferenceField(User, required=False)
# badges = {
# "cnc": {
......@@ -170,7 +170,7 @@ badges = [
},
{
"name" : "laser",
"lvl" : "5"
"lvl" : "0"
},
{
"name" : "impression3d",
......@@ -186,7 +186,7 @@ badges = [
},
{
"name" : "badge",
"lvl" : 1
"lvl" : "0"
}
]
......@@ -200,7 +200,7 @@ class User(db.Document, UserMixin):
password = db.StringField(max_length=255)
confirmed_at = db.DateTimeField()
# badges = db.DictField(default = badges)
# badges = db.ListField(db.EmbeddedDocumentField(Badge))
badges = db.DictField()
roles = db.ListField(db.ReferenceField(Role))
#badges = db.ListField( db.ReferenceField(Badges))
# dashboard_view_count = db.StringField(max_length=3, default=[0])
......@@ -310,7 +310,7 @@ def check_quiz(id):
quiz = copy.deepcopy(quizzes[id])
badge = quiz['badge']
# print(badge)
badge =str(badge)
badge = str(badge)
quiz['questions'] = sorted(quiz['questions'], key=lambda q: ordering.index(quiz['questions'].index(q)))
answers = dict( (int(k), quiz['questions'][int(k)]['options'][int(v)]) for k, v in request.form.items() if k != 'ord' )
if not len(answers.keys()):
......@@ -328,19 +328,13 @@ def check_quiz(id):
if number_correct >= badge_ok:
#award badge
print('award badge ' + badge)
# dbObjBadge = User.objects(id = C_user, badges=[badge])
# print(dbObjBadge)
# update = bdd.user.update({"_id": ObjectId(C_user)}, {"$set": {"badges.badge" : 1}}, upsert=True)
# before help -- update = bdd.user.update({"_id": C_user, "badges": { '$elemMatch': {"badges" : badge}}}, {"$set": { "badges.$.lvl": 333 }}, upsert = True)
#update = bdd.user.update({"_id": C_user}, { "$set": { "badges.$[elem].lvl": "10" } }, { "arrayFilters": [{ "elem.name": badge }]})
#print(update)
# .objects(id=post.id).update(title='Example Post')
## update_Query = str('"set__badges__' + badge + '__lvl = 1", upsert = True')
## print(update_Query)
## User.objects(id = C_user).update(update_Query)#set__badges__laser__lvl = 22 , upsert=True) #{'badge.lvl' : 1 }, upsert = True )
# print({ "badges.name": badge,"_id": ObjectId(user)}, {"$set": {"badges.$.lvl": 2}})
#({'badges.name': 'electronique', '_id': ObjectId('5b3f847e5087266741cf1fef')}, {'$set': {'badges.$.lvl': 1}})
updateUser = User.objects.get(id= C_user)
dbbadge = Badge.objects(name=badge)
updateUser.badges = dbbadge
print(updateUser.badges)
updateUser.save(validate=False)
print(updateUser)
print(dbbadge)
success_message = gettext(" Felicitation vous avez le badge : ") + badge +"<i class='material-icons'>sentiment_satisfied</i>"
flash(success_message, 'alert-success')
else:
......
......@@ -728,7 +728,35 @@ ul#menuSecond li a:hover {
footer {
background: #2c3e50;
height: 200px;
height: auto;
padding-top: 100px;
padding-bottom: 100px;
}
footer img.logo-partn {
max-width: 300px;
}
footer img.social-logo {
max-width: 60px;
}
footer h4 {
color: white;
}
footer ul {
list-style-type: none;
display: inline-block;
}
footer li {
text-align: center;
float: left;
}
footer address {
color: white;
}
footer p.contact {
color: white;
}
footer p.contact a {
color: lightgrey;
}
@media only screen and (max-width: 825px) {
......
......@@ -767,10 +767,37 @@ ul {
}
footer {
background: #2c3e50;
height: 200px;
}
footer {
background: #2c3e50;
height: auto;
padding-top: 100px;
padding-bottom: 100px;
img.logo-partn{
max-width: 300px;
}
img.social-logo{
max-width: 60px;
}
h4{
color: white;
}
ul{
list-style-type: none;
display: inline-block;
}
li{
text-align: center;
float: left;
}
address{
color: white;
}
p.contact{
color: white;
a{color: lightgrey}
}
}
......