Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mariocesar committed Sep 6, 2021
1 parent 171cd5b commit f841134
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/aseb/core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from django.http import HttpRequest, JsonResponse
from django.urls import path
from django.utils.text import capfirst
from rest_framework.viewsets import ViewSetMixin, _check_attr_name

from aseb.core.utils import request_json_response

Expand Down Expand Up @@ -121,6 +120,7 @@ def wrapper(*args, **kwargs):
urlpatterns = super().get_urls()
extra_actions = getmembers(self.__class__, lambda prop: hasattr(prop, "detail"))
extra_actions = [method for name, method in extra_actions]
opts = self.model._meta

for action_view in extra_actions:
if action_view.detail:
Expand All @@ -130,7 +130,7 @@ def wrapper(*args, **kwargs):
f"<path:object_id>/{action_view.url_name}/",
wrap(self.detail_view),
{"action_view": action_view},
name=f"{self.model._meta.app_label}_{self.model._meta.model_name}_{action_view.url_name}",
name=f"{opts.app_label}_{opts.model_name}_{action_view.url_name}",
),
)

Expand All @@ -147,6 +147,7 @@ def detail_view(self, request, object_id, action_view):

if not self.has_view_or_change_permission(request, obj):
raise PermissionDenied

context = {
**self.admin_site.each_context(request),
"object_id": object_id,
Expand Down

0 comments on commit f841134

Please sign in to comment.