Replaced self.request.resolver_match.kwargs with self.kwargs in the class-based views in the Mia core application.
This commit is contained in:
parent
dc27293381
commit
6fb74a9a8c
@ -185,8 +185,8 @@ class FormView(View):
|
|||||||
|
|
||||||
def get_current_object(self) -> Optional[Model]:
|
def get_current_object(self) -> Optional[Model]:
|
||||||
"""Finds and returns the current object, or None on a create form."""
|
"""Finds and returns the current object, or None on a create form."""
|
||||||
if "pk" in self.request.resolver_match.kwargs:
|
if "pk" in self.kwargs:
|
||||||
pk = self.request.resolver_match.kwargs["pk"]
|
pk = self.kwargs["pk"]
|
||||||
try:
|
try:
|
||||||
return self._model.objects.get(pk=pk)
|
return self._model.objects.get(pk=pk)
|
||||||
except self._model.DoesNotExist:
|
except self._model.DoesNotExist:
|
||||||
@ -232,7 +232,7 @@ class UserListView(ListView):
|
|||||||
class UserView(DetailView):
|
class UserView(DetailView):
|
||||||
"""The view of a user."""
|
"""The view of a user."""
|
||||||
def get_object(self, queryset=None):
|
def get_object(self, queryset=None):
|
||||||
return self.request.resolver_match.kwargs["user"]
|
return self.kwargs["user"]
|
||||||
|
|
||||||
|
|
||||||
@method_decorator(login_required, name="dispatch")
|
@method_decorator(login_required, name="dispatch")
|
||||||
@ -278,8 +278,8 @@ class UserFormView(FormView):
|
|||||||
|
|
||||||
def get_current_object(self) -> Optional[Model]:
|
def get_current_object(self) -> Optional[Model]:
|
||||||
"""Returns the current object, or None on a create form."""
|
"""Returns the current object, or None on a create form."""
|
||||||
if "user" in self.request.resolver_match.kwargs:
|
if "user" in self.kwargs:
|
||||||
return self.request.resolver_match.kwargs["user"]
|
return self.kwargs["user"]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user