|
6 | 6 | from collections import Counter |
7 | 7 | from typing import TYPE_CHECKING, Any |
8 | 8 |
|
| 9 | +from django.conf import settings |
9 | 10 | from django.contrib.auth.decorators import login_required |
10 | 11 | from django.db import transaction |
| 12 | +from django.db.models import Q |
11 | 13 | from django.http import HttpResponse |
12 | 14 | from django.shortcuts import get_object_or_404, redirect |
13 | 15 | from django.urls import reverse |
@@ -373,9 +375,13 @@ def show_project(request: AuthenticatedHttpRequest, obj): |
373 | 375 | last_changes = all_changes.recent() |
374 | 376 | last_announcements = all_changes.filter_announcements().recent() |
375 | 377 |
|
376 | | - all_components = obj.get_child_components_access( |
377 | | - user, lambda qs: qs.filter(category=None) |
378 | | - ) |
| 378 | + def filter_components(qs): |
| 379 | + qs = qs.filter(category=None) |
| 380 | + if settings.HIDE_SHARED_GLOSSARY_COMPONENTS: |
| 381 | + qs = qs.exclude(Q(is_glossary=True) & ~Q(project=obj)) |
| 382 | + return qs |
| 383 | + |
| 384 | + all_components = obj.get_child_components_access(user, filter_components) |
379 | 385 | all_components = get_paginator(request, all_components, stats=True) |
380 | 386 | for component in all_components: |
381 | 387 | component.is_shared = None if component.project == obj else component.project |
|
0 commit comments