Skip to content

Commit

Permalink
update permissions in races app for #32
Browse files Browse the repository at this point in the history
  • Loading branch information
ericoc committed Apr 15, 2024
1 parent 01fdf8a commit 0293441
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 36 deletions.
16 changes: 4 additions & 12 deletions ishar/apps/races/admin/affinity.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,13 @@ def has_module_permission(self, request, obj=None) -> bool:
return False

def has_add_permission(self, request, obj=None) -> bool:
if request.user and not request.user.is_anonymous:
return request.user.is_god()
return False
return self.has_module_permission(request, obj)

def has_change_permission(self, request, obj=None) -> bool:
if request.user and not request.user.is_anonymous:
return request.user.is_god()
return False
return self.has_module_permission(request, obj)

def has_delete_permission(self, request, obj=None) -> bool:
if request.user and not request.user.is_anonymous:
return request.user.is_god()
return False
return self.has_module_permission(request, obj)

def has_view_permission(self, request, obj=None) -> bool:
if request.user and not request.user.is_anonymous:
return request.user.is_eternal()
return False
return self.has_module_permission(request, obj)
16 changes: 4 additions & 12 deletions ishar/apps/races/admin/inlines/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,13 @@ def has_module_permission(self, request, obj=None) -> bool:
return False

def has_add_permission(self, request, obj=None) -> bool:
if request.user and not request.user.is_anonymous:
return request.user.is_god()
return False
return self.has_module_permission(request, obj)

def has_change_permission(self, request, obj=None) -> bool:
if request.user and not request.user.is_anonymous:
return request.user.is_god()
return False
return self.has_module_permission(request, obj)

def has_delete_permission(self, request, obj=None) -> bool:
if request.user and not request.user.is_anonymous:
return request.user.is_god()
return False
return self.has_module_permission(request, obj)

def has_view_permission(self, request, obj=None) -> bool:
if request.user and not request.user.is_anonymous:
return request.user.is_eternal()
return False
return self.has_module_permission(request, obj)
16 changes: 4 additions & 12 deletions ishar/apps/races/admin/race.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,13 @@ def has_module_permission(self, request, obj=None) -> bool:
return False

def has_add_permission(self, request, obj=None) -> bool:
if request.user and not request.user.is_anonymous:
return request.user.is_god()
return False
return self.has_module_permission(request, obj)

def has_change_permission(self, request, obj=None) -> bool:
if request.user and not request.user.is_anonymous:
return request.user.is_god()
return False
return self.has_module_permission(request, obj)

def has_delete_permission(self, request, obj=None) -> bool:
if request.user and not request.user.is_anonymous:
return request.user.is_god()
return False
return self.has_module_permission(request, obj)

def has_view_permission(self, request, obj=None) -> bool:
if request.user and not request.user.is_anonymous:
return request.user.is_eternal()
return False
return self.has_module_permission(request, obj)

0 comments on commit 0293441

Please sign in to comment.