mirror of https://gitlab.crans.org/bde/nk20
Always query distinct objects
This commit is contained in:
parent
0ae61f3643
commit
2f018f8c9d
|
@ -131,7 +131,7 @@ class UserDetailView(ProtectQuerysetMixin, LoginRequiredMixin, DetailView):
|
||||||
"""
|
"""
|
||||||
We can't display information of a not registered user.
|
We can't display information of a not registered user.
|
||||||
"""
|
"""
|
||||||
return super().get_queryset().filter(profile__registration_valid=True).distinct()
|
return super().get_queryset().filter(profile__registration_valid=True)
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
|
|
|
@ -33,7 +33,9 @@ class TransactionCreateView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTabl
|
||||||
extra_context = {"title": _("Transfer money")}
|
extra_context = {"title": _("Transfer money")}
|
||||||
|
|
||||||
def get_queryset(self, **kwargs):
|
def get_queryset(self, **kwargs):
|
||||||
return super().get_queryset(**kwargs).order_by("-created_at").all()[:20]
|
return Transaction.objects.filter(
|
||||||
|
PermissionBackend.filter_queryset(self.request.user, Transaction, "view")
|
||||||
|
).order_by("-created_at").all()[:20]
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
@ -139,7 +141,9 @@ class ConsoView(ProtectQuerysetMixin, LoginRequiredMixin, SingleTableView):
|
||||||
table_class = HistoryTable
|
table_class = HistoryTable
|
||||||
|
|
||||||
def get_queryset(self, **kwargs):
|
def get_queryset(self, **kwargs):
|
||||||
return super().get_queryset(**kwargs).order_by("-created_at")[:20]
|
return Transaction.objects.filter(
|
||||||
|
PermissionBackend.filter_queryset(self.request.user, Transaction, "view")
|
||||||
|
).order_by("-created_at").all()[:20]
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -20,7 +20,7 @@ class ProtectQuerysetMixin:
|
||||||
"""
|
"""
|
||||||
def get_queryset(self, **kwargs):
|
def get_queryset(self, **kwargs):
|
||||||
qs = super().get_queryset(**kwargs)
|
qs = super().get_queryset(**kwargs)
|
||||||
return qs.filter(PermissionBackend.filter_queryset(self.request.user, qs.model, "view"))
|
return qs.filter(PermissionBackend.filter_queryset(self.request.user, qs.model, "view")).distinct()
|
||||||
|
|
||||||
def get_form(self, form_class=None):
|
def get_form(self, form_class=None):
|
||||||
form = super().get_form(form_class)
|
form = super().get_form(form_class)
|
||||||
|
|
Loading…
Reference in New Issue