[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
)
)
users = users.filter(is_active=True)
group_perms = GroupPackagePermission.objects.filter(package=current_package)
groups = Group.objects.exclude(
@ -2699,8 +2700,10 @@ def group(request, group_uuid):
context["group"] = current_group
context["users"] = UserManager.get_users_lp().exclude(
id__in=current_group.user_member.all()
context["users"] = (
UserManager.get_users_lp()
.exclude(id__in=current_group.user_member.all())
.filter(is_active=True)
)
context["groups"] = (
GroupManager.get_groups_lp()

View File

@ -93,7 +93,10 @@
>
{% csrf_token %}
<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="action" value="remove" />
<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="col-span-5 truncate">
{{ up.user.username }}
{% if not up.user.is_active %}<i>(inactive)</i>{% endif %}
<input
type="hidden"
name="grantee"

View File

@ -57,7 +57,8 @@
{% for um in group.user_member.all %}
<li>
<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>
{% endfor %}