Merge pull request #999 from dod-ccpo/ccpo-user-list

Page for CCPO users list
This commit is contained in:
leigh-mil 2019-08-06 13:18:57 -04:00 committed by GitHub
commit 86b66e5685
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 76 additions and 1 deletions

View File

@ -17,6 +17,7 @@ class PermissionSets(object):
EDIT_PORTFOLIO_ADMIN = "edit_portfolio_admin" EDIT_PORTFOLIO_ADMIN = "edit_portfolio_admin"
PORTFOLIO_POC = "portfolio_poc" PORTFOLIO_POC = "portfolio_poc"
VIEW_AUDIT_LOG = "view_audit_log" VIEW_AUDIT_LOG = "view_audit_log"
MANAGE_CCPO_USERS = "manage_ccpo_users"
VIEW_APPLICATION = "view_application" VIEW_APPLICATION = "view_application"
EDIT_APPLICATION_ENVIRONMENTS = "edit_application_environments" EDIT_APPLICATION_ENVIRONMENTS = "edit_application_environments"
@ -56,7 +57,17 @@ ATAT_PERMISSION_SETS = [
"display_name": "View Audit Log", "display_name": "View Audit Log",
"description": "", "description": "",
"permissions": [Permissions.VIEW_AUDIT_LOG], "permissions": [Permissions.VIEW_AUDIT_LOG],
} },
{
"name": PermissionSets.MANAGE_CCPO_USERS,
"display_name": "View Audit Log",
"description": "",
"permissions": [
Permissions.VIEW_CCPO_USER,
Permissions.EDIT_CCPO_USER,
Permissions.DELETE_CCPO_USER,
],
},
] ]
_PORTFOLIO_BASIC_PERMISSION_SETS = [ _PORTFOLIO_BASIC_PERMISSION_SETS = [

View File

@ -28,6 +28,10 @@ class Users(object):
return user return user
@classmethod
def get_ccpo_users(cls):
return db.session.query(User).filter(User.permission_sets != None).all()
@classmethod @classmethod
def create(cls, dod_id, permission_sets=None, **kwargs): def create(cls, dod_id, permission_sets=None, **kwargs):
if permission_sets: if permission_sets:

View File

@ -1,5 +1,9 @@
class Permissions(object): class Permissions(object):
# ccpo permissions
VIEW_AUDIT_LOG = "view_audit_log" VIEW_AUDIT_LOG = "view_audit_log"
VIEW_CCPO_USER = "view_ccpo_user"
EDIT_CCPO_USER = "edit_ccpo_user"
DELETE_CCPO_USER = "delete_ccpo_user"
# base portfolio perms # base portfolio perms
VIEW_PORTFOLIO = "view_portfolio" VIEW_PORTFOLIO = "view_portfolio"

View File

@ -132,6 +132,13 @@ def activity_history():
return render_template("audit_log/audit_log.html", audit_events=audit_events) return render_template("audit_log/audit_log.html", audit_events=audit_events)
@bp.route("/ccpo-users")
@user_can(Permissions.VIEW_CCPO_USER, message="view ccpo users")
def ccpo_users():
users = Users.get_ccpo_users()
return render_template("ccpo/users.html", users=users)
@bp.route("/about") @bp.route("/about")
def about(): def about():
return render_template("about.html") return render_template("about.html")

View File

@ -31,6 +31,7 @@ _ALL_PERMS = [
PermissionSets.EDIT_PORTFOLIO_ADMIN, PermissionSets.EDIT_PORTFOLIO_ADMIN,
PermissionSets.PORTFOLIO_POC, PermissionSets.PORTFOLIO_POC,
PermissionSets.VIEW_AUDIT_LOG, PermissionSets.VIEW_AUDIT_LOG,
PermissionSets.MANAGE_CCPO_USERS,
] ]

27
templates/ccpo/users.html Normal file
View File

@ -0,0 +1,27 @@
{% extends "base.html" %}
{% block content %}
<div class='col'>
<div class="h2">
CCPO Users
</div>
<table>
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>DoD ID</th>
</tr>
</thead>
<tbody>
{% for user in users %}
<tr>
<td>{{ user.full_name }}</td>
<td>{{ user.email }}</td>
<td>{{ user.dod_id }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}

View File

@ -74,3 +74,14 @@ def test_update_user_with_last_login():
last_login = new_user.last_login last_login = new_user.last_login
Users.update_last_login(new_user) Users.update_last_login(new_user)
assert new_user.last_login > last_login assert new_user.last_login > last_login
def test_get_ccpo_users():
ccpo_1 = UserFactory.create_ccpo()
ccpo_2 = UserFactory.create_ccpo()
rando = UserFactory.create()
ccpo_users = Users.get_ccpo_users()
assert ccpo_1 in ccpo_users
assert ccpo_2 in ccpo_users
assert rando not in ccpo_users

View File

@ -120,6 +120,16 @@ def test_atst_activity_history_access(get_url_assert_status):
get_url_assert_status(rando, url, 404) get_url_assert_status(rando, url, 404)
# atst.ccpo_users
def test_atst_ccpo_users_access(get_url_assert_status):
ccpo = user_with(PermissionSets.MANAGE_CCPO_USERS)
rando = user_with()
url = url_for("atst.ccpo_users")
get_url_assert_status(ccpo, url, 200)
get_url_assert_status(rando, url, 404)
# applications.access_environment # applications.access_environment
def test_applications_access_environment_access(get_url_assert_status): def test_applications_access_environment_access(get_url_assert_status):
dev = UserFactory.create() dev = UserFactory.create()