diff --git a/usaon_vta_survey/constants/roles.py b/usaon_vta_survey/constants/roles.py index 97e880b6..ef3b73d2 100644 --- a/usaon_vta_survey/constants/roles.py +++ b/usaon_vta_survey/constants/roles.py @@ -1,5 +1,5 @@ ROLES = [ 'admin', - # 'respondent', + 'respondent', # 'analyst', ] diff --git a/usaon_vta_survey/routes/__init__.py b/usaon_vta_survey/routes/__init__.py index 4e7f74bc..92acccdf 100644 --- a/usaon_vta_survey/routes/__init__.py +++ b/usaon_vta_survey/routes/__init__.py @@ -8,3 +8,4 @@ import usaon_vta_survey.routes.profile import usaon_vta_survey.routes.survey import usaon_vta_survey.routes.surveys +import usaon_vta_survey.routes.users diff --git a/usaon_vta_survey/routes/users.py b/usaon_vta_survey/routes/users.py new file mode 100644 index 00000000..6f3a18c1 --- /dev/null +++ b/usaon_vta_survey/routes/users.py @@ -0,0 +1,13 @@ +from flask import render_template + +from usaon_vta_survey import app +from usaon_vta_survey.models.tables import User + + +@app.route('/users') +def view_users(): + users = User.query.order_by(User.name).all() + return render_template( + 'users.html', + users=users, + ) diff --git a/usaon_vta_survey/templates/base.html b/usaon_vta_survey/templates/base.html index 08736176..98ab71cd 100644 --- a/usaon_vta_survey/templates/base.html +++ b/usaon_vta_survey/templates/base.html @@ -1,4 +1,4 @@ -{% from 'macros/user_login_management_buttons.j2' import user_login_buttons %} +{% from 'macros/login_button_or_private_nav_buttons.j2' import user_login_buttons %} diff --git a/usaon_vta_survey/templates/macros/login_button_or_private_nav_buttons.j2 b/usaon_vta_survey/templates/macros/login_button_or_private_nav_buttons.j2 new file mode 100644 index 00000000..d70719b1 --- /dev/null +++ b/usaon_vta_survey/templates/macros/login_button_or_private_nav_buttons.j2 @@ -0,0 +1,15 @@ +{% macro user_login_buttons(current_user) -%} + {% if current_user.is_authenticated %} + {% if current_user.role=='admin' %} + Profile + Users + Logout + {% else %} + Profile + Logout + {% endif %} + {% else %} + Login + {% endif %} + +{%- endmacro -%} diff --git a/usaon_vta_survey/templates/macros/user_login_management_buttons.j2 b/usaon_vta_survey/templates/macros/user_login_management_buttons.j2 deleted file mode 100644 index c3449ccd..00000000 --- a/usaon_vta_survey/templates/macros/user_login_management_buttons.j2 +++ /dev/null @@ -1,9 +0,0 @@ -{% macro user_login_buttons(current_user) -%} - {% if current_user.is_authenticated %} - Profile - Logout - {% else %} - Login - {% endif %} - -{%- endmacro -%} diff --git a/usaon_vta_survey/templates/users.html b/usaon_vta_survey/templates/users.html new file mode 100644 index 00000000..cb4a5956 --- /dev/null +++ b/usaon_vta_survey/templates/users.html @@ -0,0 +1,35 @@ +{% extends 'base.html' %} + + +{% block content %} +

{% block title %}Users{% endblock %}

+ + {% if not current_user.is_authenticated %} +

Please login to view this page.

+ {% else %} + {% if not current_user.role=='admin' %} +

You don't belong here! This page is for admins only.

+ {% else %} + + + + + + + + + + {% for user in users %} + + + + + + + + {% endfor %} + +
idNameRoleAffiliationBio
{{user.id}} {{user.name}}{{user.role}}{{user.affiliation}}{{user.biography}}
+ {% endif %} + {% endif %} +{% endblock %}