Skip to content

Commit

Permalink
Merge pull request #1050 from CodingPirates/1025-feature-side-med-ema…
Browse files Browse the repository at this point in the history
…il-indhold

Check for user rights for emails
  • Loading branch information
lakridserne authored May 26, 2024
2 parents f685273 + fe5ec15 commit 8972078
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions members/admin/emailitem_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,17 @@ class EmailItemAdmin(admin.ModelAdmin):
)
readonly_fields = ("created_dtm", "send_error", "sent_dtm")

def get_queryset(self, request):
qs = super(EmailItemAdmin, self).get_queryset(request)
if request.user.is_superuser or request.user.has_perm(
"members.view_all_departments"
):
return qs
departments = Department.objects.filter(adminuserinformation__user=request.user)
return qs.filter(department__in=departments) | qs.filter(
activity__department__in=departments
)

fieldsets = [
(
"Modtager information",
Expand Down

0 comments on commit 8972078

Please sign in to comment.