From b1946b24d6b3926c1b4937d41d5d3e7260a612fd Mon Sep 17 00:00:00 2001 From: Robert Date: Wed, 11 Dec 2024 16:19:39 -0500 Subject: [PATCH] glamr/views: exclude private data from record views Closes #59. --- mibios/glamr/views.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mibios/glamr/views.py b/mibios/glamr/views.py index 788e96e..8f7d8cb 100644 --- a/mibios/glamr/views.py +++ b/mibios/glamr/views.py @@ -1468,7 +1468,9 @@ def get_relations(self): except AttributeError: # this is the m2m field rel_attr = i.name - qs = getattr(self.object, rel_attr).all()[:self.max_to_many] + qs = getattr(self.object, rel_attr).all() + qs = exclude_private_data(qs) + qs = qs[:self.max_to_many] data.append((name, model_name, qs, i)) return data @@ -1485,7 +1487,9 @@ def get_detail_for_field(self, field): except AttributeError: # this is the m2m field rel_attr = f.name - value = getattr(self.object, rel_attr).count() + qs = getattr(self.object, rel_attr).all() + value = exclude_private_data(qs).count() + del qs is_blank = (value == 0) # Let's not show zeros elif f.one_to_one: # 1-1 fields don't have a verbose name