Add shorts exam count to collection annotations and update display logic
This commit is contained in:
+28
-6
@@ -5350,23 +5350,44 @@ class ExamCollectionList(ListView):
|
||||
base_qs = base_qs.filter(archive=False)
|
||||
|
||||
# Build annotation kwargs dynamically so counts respect the show_archived toggle.
|
||||
# Count exams regardless of exam_mode; include archived depending on the toggle.
|
||||
if show_archived:
|
||||
# include archived exams in counts
|
||||
# include archived exams in counts (count all exams for each app)
|
||||
counts = {
|
||||
"anatomy_count": Count("anatomy_exams"),
|
||||
"longs_count": Count("longs_exams"),
|
||||
"physics_count": Count("physics_exams"),
|
||||
"rapids_count": Count("rapids_exams"),
|
||||
"sbas_count": Count("sbas_exams"),
|
||||
"shorts_count": Count("shorts_exams"),
|
||||
}
|
||||
else:
|
||||
# only count non-archived exams
|
||||
counts = {
|
||||
"anatomy_count": Count("anatomy_exams", filter=Q(anatomy_exams__archive=False)),
|
||||
"longs_count": Count("longs_exams", filter=Q(longs_exams__archive=False)),
|
||||
"physics_count": Count("physics_exams", filter=Q(physics_exams__archive=False)),
|
||||
"rapids_count": Count("rapids_exams", filter=Q(rapids_exams__archive=False)),
|
||||
"sbas_count": Count("sbas_exams", filter=Q(sbas_exams__archive=False)),
|
||||
"anatomy_count": Count(
|
||||
"anatomy_exams",
|
||||
filter=Q(anatomy_exams__archive=False),
|
||||
),
|
||||
"longs_count": Count(
|
||||
"longs_exams",
|
||||
filter=Q(longs_exams__archive=False),
|
||||
),
|
||||
"physics_count": Count(
|
||||
"physics_exams",
|
||||
filter=Q(physics_exams__archive=False),
|
||||
),
|
||||
"rapids_count": Count(
|
||||
"rapids_exams",
|
||||
filter=Q(rapids_exams__archive=False),
|
||||
),
|
||||
"sbas_count": Count(
|
||||
"sbas_exams",
|
||||
filter=Q(sbas_exams__archive=False),
|
||||
),
|
||||
"shorts_count": Count(
|
||||
"shorts_exams",
|
||||
filter=Q(shorts_exams__archive=False),
|
||||
),
|
||||
}
|
||||
|
||||
qs = (
|
||||
@@ -5378,6 +5399,7 @@ class ExamCollectionList(ListView):
|
||||
+ F("physics_count")
|
||||
+ F("rapids_count")
|
||||
+ F("sbas_count")
|
||||
+ F("shorts_count")
|
||||
)
|
||||
.prefetch_related("author")
|
||||
.order_by("name")
|
||||
|
||||
Reference in New Issue
Block a user