Commit 02f44b11 authored by colmoneill's avatar colmoneill

a button to access the admin if your user has the appropriate rights

parent a89af03b
......@@ -190,6 +190,9 @@ class User(db.Document, UserMixin):
meta = {'strict': False}
class ExtendedRegisterForm(RegisterForm):
first_name = StringField('prenom', validators=[DataRequired()])
last_name = StringField('nom', validators=[DataRequired()])
......@@ -242,6 +245,7 @@ def index():
latest = sorted(articles, reverse=True,
key=lambda p: p.meta['published'])
return render_template("home.html" ,events=events ,articles=latest[:4])
@app.route("/learn")
......@@ -320,11 +324,11 @@ def check_quiz(id):
# print({ "badges.name": badge,"_id": ObjectId(user)}, {"$set": {"badges.$.lvl": 2}})
#({'badges.name': 'electronique', '_id': ObjectId('5b3f847e5087266741cf1fef')}, {'$set': {'badges.$.lvl': 1}})
success_message = gettext("<i class='material-icons md-48'>sentiment_satisfied</i> Felicitation vous avez le badge : ") + badge +"</br>"
success_message = gettext(" Felicitation vous avez le badge : ") + badge +"<i class='material-icons'>sentiment_satisfied</i>"
flash(success_message, 'alert-success')
else:
print('user got less than required amount')
fail_message = gettext(" <i class='material-icons md-48'>sentiment_dissatisfied</i> ohhh non tu n'as pas eu assez de bonne reponses ! </br> ")
fail_message = gettext("ohhh non tu n'as pas eu assez de bonne reponses !") + "<i class='material-icons'>sentiment_dissatisfied</i>"
flash(fail_message, 'alert-danger')
return render_template('check_quiz.html', quiz=quiz, question_answer=zip(quiz['questions'], answers_list), correct=number_correct, total=len(answers_list))
......@@ -402,6 +406,9 @@ class UserView(ModelView):
# redirect to login page if user doesn't have access
return redirect(url_for('security.login', next=request.url))
def has_role(self, role):
return role in self.roles
column_list = ('first_name', 'email' , 'roles')
column_sortable_list = ('email')
......
......@@ -25,12 +25,7 @@
<p>{{page}}</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Les technologies numériques de fabrication permettent à tous d’imaginer et de réaliser ses créations. Impression 3D, découpes et gravures laser, modules électroniques, programmation, robots, tout est là pour te permettre de réaliser tes projets. Envie de comprendre ces technologies, d’apprendre à utiliser ces outils numériques ou encore de découvrir quelques projets à réaliser toi même? Le fablab mobile et le programme BeMaker sont là pour t’accompagner.</p>
<div class="spacer"></div>
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-4 ">
......
......@@ -21,8 +21,11 @@
<ul id="menuSecond">
{% if current_user.is_authenticated %}
{% if current_user.has_role('admin') %}
<li><a href="/admin"><button type="button" class="btn btn-outline-secondary btn-sm">{{_("access admin tools")}}</button></a></li>
{% endif %}
<li><a href="/dashboard">{{_("mon profil")}}</a></li>
<li><a href="{{ url_for('security.logout') }}">{{_("deconnection")}}</a></li>
<li><a href="{{ url_for('security.logout') }}">{{_("deconnection")}}</a></li>
{% else %}
{% include "security/_menu.html" %}
{% endif %}
......@@ -48,8 +51,12 @@
<li class="item"><a href="/contact">{{_("contact")}}</a><span class="deco"></li>
<li><hr></li>
{% if current_user.is_authenticated %}
<li><a href="/dashboard">{{_("mon profil")}}</a></li>
<li><a href="{{ url_for('security.logout') }}">{{_("deconnection")}}</a></li>
{% if current_user.has_role('admin') %}
test
<li><a href="/admin">Manage Site</a></li>
{% endif %}
<li><a href="/dashboard">{{_("mon profil")}}</a></li>
<li><a href="{{ url_for('security.logout') }}">{{_("deconnection")}}</a></li>
{% else %}
{% include "security/_menu.html" %}
{% endif %}
......
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