Skip to content

Commit

Permalink
glamr/views: exclude private data from record views
Browse files Browse the repository at this point in the history
Closes #59.
  • Loading branch information
robert102 committed Dec 11, 2024
1 parent 6c73624 commit b1946b2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mibios/glamr/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit b1946b2

Please sign in to comment.