From 048af017950555244ec9c9d120410ea40c862be7 Mon Sep 17 00:00:00 2001 From: mpeltriaux Date: Wed, 19 Oct 2022 07:24:00 +0200 Subject: [PATCH] Landing page shared count fix * fixes bug where count of shared entries on landing page would ignore team-shared entries * restore prior editable column icon rendering --- konova/utils/tables.py | 2 +- konova/views/home.py | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/konova/utils/tables.py b/konova/utils/tables.py index 795c6bab..d64c7666 100644 --- a/konova/utils/tables.py +++ b/konova/utils/tables.py @@ -216,7 +216,7 @@ class TableRenderMixin: html += self.render_icn( tooltip=_("Full access granted") if has_access else _("Access not granted"), - icn_class="fas fa-share-alt rlp-r-inv" if has_access else "", + icn_class="fas fa-edit rlp-r-inv" if has_access else "far fa-edit", ) return format_html(html) diff --git a/konova/views/home.py b/konova/views/home.py index 3118956c..98cbaee3 100644 --- a/konova/views/home.py +++ b/konova/views/home.py @@ -6,6 +6,7 @@ Created on: 19.08.22 """ from django.contrib.auth.decorators import login_required +from django.db.models import Q from django.http import HttpRequest from django.shortcuts import render from django.utils import timezone @@ -50,22 +51,22 @@ def home_view(request: HttpRequest): ) # Then fetch only user related ones user_interventions = interventions.filter( - users__in=[user] - ) + Q(users__in=[user]) | Q(teams__in=user.shared_teams) + ).distinct() # Repeat for other objects comps = Compensation.objects.filter( deleted=None, ) user_comps = comps.filter( - intervention__users__in=[user] - ) + Q(intervention__users__in=[user]) | Q(intervention__teams__in=user.shared_teams) + ).distinct() eco_accs = EcoAccount.objects.filter( deleted=None, ) user_ecco_accs = eco_accs.filter( - users__in=[user] - ) + Q(users__in=[user]) | Q(teams__in=user.shared_teams) + ).distinct() additional_context = { "msgs": msgs,