mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-11 09:28:27 -04:00
Combine invited and active team members
Right now these are two separate lists. Which makes it harder to add improvements that will make large numbers of users easier to manage.
This commit is contained in:
@@ -28,15 +28,18 @@ from app.utils import user_has_permissions
|
||||
@login_required
|
||||
@user_has_permissions('view_activity', admin_override=True)
|
||||
def manage_users(service_id):
|
||||
users = user_api_client.get_users_for_service(service_id=service_id)
|
||||
invited_users = [invite for invite in invite_api_client.get_invites_for_service(service_id=service_id)
|
||||
if invite.status != 'accepted']
|
||||
users = (
|
||||
user_api_client.get_users_for_service(service_id=service_id) +
|
||||
[
|
||||
invite for invite in invite_api_client.get_invites_for_service(service_id=service_id)
|
||||
if invite.status != 'accepted'
|
||||
]
|
||||
)
|
||||
|
||||
return render_template(
|
||||
'views/manage-users.html',
|
||||
users=users,
|
||||
current_user=current_user,
|
||||
invited_users=invited_users
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -30,15 +30,19 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<h2 class="visually-hidden">
|
||||
Active
|
||||
</h2>
|
||||
<div class="user-list">
|
||||
{% for user in users %}
|
||||
<div class="user-list-item">
|
||||
<h3>
|
||||
<span class="heading-small">{{ user.name }}</span> <span class="hint">
|
||||
{%- if user.email_address == current_user.email_address -%}
|
||||
{%- if user.name -%}
|
||||
<span class="heading-small">{{ user.name }}</span> 
|
||||
{%- endif -%}
|
||||
<span class="hint">
|
||||
{%- if user.status == 'pending' -%}
|
||||
{{ user.email_address }} (pending)
|
||||
{%- elif user.status == 'cancelled' -%}
|
||||
{{ user.email_address }} (cancelled invite)
|
||||
{%- elif user.email_address == current_user.email_address -%}
|
||||
(you)
|
||||
{% else %}
|
||||
{{ user.email_address }}
|
||||
@@ -74,66 +78,17 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if current_user.has_permissions('manage_users', admin_override=True) %}
|
||||
{% if current_user.id != user.id %}
|
||||
<li class="tick-cross-list-edit-link">
|
||||
<li class="tick-cross-list-edit-link">
|
||||
{% if user.status == 'pending' %}
|
||||
<a href="{{ url_for('.cancel_invited_user', service_id=current_service.id, invited_user_id=user.id)}}">Cancel invitation</a>
|
||||
{% elif user.status == 'active' and current_user.id != user.id %}
|
||||
<a href="{{ url_for('.edit_user_permissions', service_id=current_service.id, user_id=user.id)}}">Edit permissions</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
{% if invited_users %}
|
||||
<h2 class="heading-medium">
|
||||
Invited
|
||||
</h2>
|
||||
<div class="user-list">
|
||||
{% for user in invited_users %}
|
||||
<div class="user-list-item">
|
||||
<h3>
|
||||
<span style="font-weight: bold">{{ user.email_address }}</span>
|
||||
</h3>
|
||||
<ul class="tick-cross-list">
|
||||
<div class="tick-cross-list-permissions">
|
||||
{{ tick_cross(
|
||||
user.has_permissions('send_texts', 'send_emails', 'send_letters'),
|
||||
'Send messages'
|
||||
) }}
|
||||
{{ tick_cross(
|
||||
user.has_permissions('manage_templates'),
|
||||
'Add and edit templates'
|
||||
) }}
|
||||
{{ tick_cross(
|
||||
user.has_permissions('manage_users', 'manage_settings'),
|
||||
'Manage service'
|
||||
) }}
|
||||
{{ tick_cross(
|
||||
user.has_permissions('manage_api_keys'),
|
||||
'Access API keys'
|
||||
) }}
|
||||
{% if 'email_auth' in current_service['permissions'] %}
|
||||
<div class="tick-cross-list-hint">
|
||||
{% if user.auth_type == 'sms_auth' %}
|
||||
Signs in with a text message code
|
||||
{% else %}
|
||||
Signs in with an email link
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<li class="tick-cross-list-edit-link">
|
||||
{% if user.status == 'pending' and current_user.has_permissions('manage_users') %}
|
||||
<a href="{{ url_for('.cancel_invited_user', service_id=current_service.id, invited_user_id=user.id)}}">Cancel invitation</a>
|
||||
{% else %}
|
||||
{{ user.status|title }}
|
||||
{% endif %}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user