[Fix] Filter Active Users (#314) (#329)

Adding users to a group or setting permissions on a package now filter for active users. Also any inactive members of group/package get marked as such.

<img width="490" alt="{3B906C71-F3AE-41E4-A61C-B8377D79F685}.png" src="attachments/09cf149a-9d7a-4560-8ce7-9f3487527ee2">

Reviewed-on: enviPath/enviPy#329
Co-authored-by: Liam Brydon <lbry121@aucklanduni.ac.nz>
Co-committed-by: Liam Brydon <lbry121@aucklanduni.ac.nz>
This commit is contained in:
2026-02-12 20:20:16 +13:00
committed by jebus
parent 73f0202267
commit 58ab5b33e3
4 changed files with 12 additions and 4 deletions

View File

@ -1049,6 +1049,7 @@ def package(request, package_uuid):
"user_id", flat=True "user_id", flat=True
) )
) )
users = users.filter(is_active=True)
group_perms = GroupPackagePermission.objects.filter(package=current_package) group_perms = GroupPackagePermission.objects.filter(package=current_package)
groups = Group.objects.exclude( groups = Group.objects.exclude(
@ -2699,8 +2700,10 @@ def group(request, group_uuid):
context["group"] = current_group context["group"] = current_group
context["users"] = UserManager.get_users_lp().exclude( context["users"] = (
id__in=current_group.user_member.all() UserManager.get_users_lp()
.exclude(id__in=current_group.user_member.all())
.filter(is_active=True)
) )
context["groups"] = ( context["groups"] = (
GroupManager.get_groups_lp() GroupManager.get_groups_lp()

View File

@ -93,7 +93,10 @@
> >
{% csrf_token %} {% csrf_token %}
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<span class="flex-1">{{ u.username }}</span> <span class="flex-1"
>{{ u.username }}
{% if not u.is_active %}<i>(inactive)</i>{% endif %}</span
>
<input type="hidden" name="member" value="{{ u.url }}" /> <input type="hidden" name="member" value="{{ u.url }}" />
<input type="hidden" name="action" value="remove" /> <input type="hidden" name="action" value="remove" />
<button type="submit" class="btn btn-error btn-sm"> <button type="submit" class="btn btn-error btn-sm">

View File

@ -146,6 +146,7 @@
<div class="grid grid-cols-12 gap-2 items-center"> <div class="grid grid-cols-12 gap-2 items-center">
<div class="col-span-5 truncate"> <div class="col-span-5 truncate">
{{ up.user.username }} {{ up.user.username }}
{% if not up.user.is_active %}<i>(inactive)</i>{% endif %}
<input <input
type="hidden" type="hidden"
name="grantee" name="grantee"

View File

@ -57,7 +57,8 @@
{% for um in group.user_member.all %} {% for um in group.user_member.all %}
<li> <li>
<a href="{{ um.url }}" class="hover:bg-base-300" <a href="{{ um.url }}" class="hover:bg-base-300"
>{{ um.username }}</a >{{ um.username }}
{% if not um.is_active %}<i>(inactive)</i>{% endif %}</a
> >
</li> </li>
{% endfor %} {% endfor %}