Skip to content

Commit

Permalink
fix: unassign roles on roster removal
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeRomaa committed Apr 9, 2024
1 parent 2cd140d commit dddcf01
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion apps/resources/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def get(self, request):

return Response(
{
category.lower(): ResourceSerializer(resources, many=True).data
category: ResourceSerializer(resources, many=True).data
for category, resources in sorted_resources.items()
}
)
Expand Down
8 changes: 5 additions & 3 deletions apps/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,14 @@ def set_membership(self, short):
return

if short is None:
self.roles.clear()

self.status = Status.NON_MEMBER
self.endorsements = None
else:
self.roles.remove(*self.roles.filter(short__in=["HC", "VC"]))
self.add_role(short)

if self.status == Status.NON_MEMBER:
self.status = Status.ACTIVE
self.endorsements = default_endorsements()
Expand All @@ -213,9 +218,6 @@ def set_membership(self, short):

self.save()

self.roles.remove(*self.roles.filter(short__in=["HC", "VC"]))
self.add_role(short)

def update_loa_status(self):
loa_filter = self.loas.filter(start__lt=date.today(), approved=True)

Expand Down

0 comments on commit dddcf01

Please sign in to comment.