diff --git a/opentech/apply/users/models.py b/opentech/apply/users/models.py index 3752a5761040f3ce1fc3e66ce5cab329e592e653..38c52a7239a5eb8cf6dac274484634f2fa9fe9a2 100644 --- a/opentech/apply/users/models.py +++ b/opentech/apply/users/models.py @@ -95,6 +95,10 @@ class User(AbstractUser): def get_short_name(self): return self.email + @cached_property + def roles(self): + return list(self.groups.values_list('name', flat=True)) + @cached_property def is_apply_staff(self): return self.groups.filter(name=STAFF_GROUP_NAME).exists() or self.is_superuser diff --git a/opentech/apply/users/templates/wagtailusers/users/list.html b/opentech/apply/users/templates/wagtailusers/users/list.html new file mode 100644 index 0000000000000000000000000000000000000000..87ec4ac5973ef81676447e6df51f5747e9c2939a --- /dev/null +++ b/opentech/apply/users/templates/wagtailusers/users/list.html @@ -0,0 +1,43 @@ +{% load i18n wagtailusers_tags wagtailadmin_tags %} +<table class="listing"> + <thead> + <tr> + <th class="name"> + {% trans "Name" %} + {% if ordering == "name" %} + <a href="{% url 'wagtailusers_users:index' %}" class="icon icon-arrow-down-after teal"></a> + {% else %} + <a href="{% url 'wagtailusers_users:index' %}?ordering=name" class="icon icon-arrow-down-after"></a> + {% endif %} + </th> + <th class="username"> + {% trans "Username" %} + {% if ordering == "username" %} + <a href="{% url 'wagtailusers_users:index' %}" class="icon icon-arrow-down-after teal"></a> + {% else %} + <a href="{% url 'wagtailusers_users:index' %}?ordering=username" class="icon icon-arrow-down-after"></a> + {% endif %} + </th> + <th class="level">{% trans "Role" %}</th> + <th class="status">{% trans "Status" %}</th> + </tr> + </thead> + <tbody> + {% for user in users %} + <tr> + <td class="title" valign="top"> + <h2> + <span class="avatar small"><img src="{% avatar_url user size=25 %}" /></span> + <a href="{% url 'wagtailusers_users:edit' user.pk %}">{{ user.get_full_name|default:user.get_username }}</a> + </h2> + <ul class="actions"> + {% user_listing_buttons user %} + </ul> + </td> + <td class="username" valign="top">{{ user.get_username }}</td> + <td class="level" valign="top">{{ user.roles|join:', ' }}{% if user.is_superuser %} ({% trans "Admin" %}){% endif %}</td> + <td class="status" valign="top"><div class="status-tag {% if user.is_active %}primary{% endif %}">{% if user.is_active %}{% trans "Active" %}{% else %}{% trans "Inactive" %}{% endif %}</div></td> + </tr> + {% endfor %} + </tbody> +</table>