Skip to content

Commit

Permalink
Update permissions for UserPreferences admin models
Browse files Browse the repository at this point in the history
Co-authored-by: Dhruv Bhanushali <[email protected]>
  • Loading branch information
AetherUnbound and dhruvkb authored Apr 10, 2024
1 parent 28f8b6b commit 3841d2d
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions api/api/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ class IndividualUserPreferencesAdmin(admin.ModelAdmin):
currently logged-in user's preferences
"""

can_delete = False
verbose_name_plural = "My Preferences"
verbose_name = "My Preferences"
form = UserPreferencesAdminForm
Expand All @@ -156,11 +155,11 @@ def get_queryset(self, request):
qs = super().get_queryset(request)
return qs.filter(user=request.user)

def has_change_permission(self, request, obj=None):
if not obj:
# the changelist itself
return True
return obj.user == request.user
def has_add_permission(*args, **kwargs):
return False

def has_delete_permission(*args, **kwargs):
return False

def changelist_view(self, request, extra_context=None):
obj = self.get_queryset(request).first()
Expand Down

0 comments on commit 3841d2d

Please sign in to comment.