diff --git a/lemarche/tenders/admin.py b/lemarche/tenders/admin.py index aaca0dafb..7580e8dd9 100644 --- a/lemarche/tenders/admin.py +++ b/lemarche/tenders/admin.py @@ -173,7 +173,7 @@ class TenderAdmin(FieldsetsInlineMixin, admin.ModelAdmin): "survey_transactioned_feedback", "survey_transactioned_answer_date", "validated_at", - "question_count_annotated_with_link", + "question_count_with_link", "siae_count_annotated_with_link", "siae_email_send_count_annotated_with_link", "siae_email_link_click_count_annotated_with_link", @@ -210,7 +210,7 @@ class TenderAdmin(FieldsetsInlineMixin, admin.ModelAdmin): "constraints", "external_link", "accept_cocontracting", - "question_count_annotated_with_link", + "question_count_with_link", ), }, ), @@ -341,7 +341,7 @@ class TenderAdmin(FieldsetsInlineMixin, admin.ModelAdmin): def get_queryset(self, request): qs = super().get_queryset(request) qs = qs.with_siae_stats() - qs = qs.with_question_stats() + # qs = qs.with_question_stats() # doesn't work when chaining these 2 querysets: adds duplicates... return qs def get_changeform_initial_data(self, request): @@ -409,12 +409,11 @@ def user_with_link(self, tender): user_with_link.short_description = "Auteur" user_with_link.admin_order_field = "author" - def question_count_annotated_with_link(self, tender): + def question_count_with_link(self, tender): url = reverse("admin:tenders_tenderquestion_changelist") + f"?tender__in={tender.id}" - return format_html(f'{getattr(tender, "question_count_annotated", 0)}') + return format_html(f'{tender.questions.count()}') - question_count_annotated_with_link.short_description = TenderQuestion._meta.verbose_name_plural - question_count_annotated_with_link.admin_order_field = "question_count_annotated" + question_count_with_link.short_description = TenderQuestion._meta.verbose_name_plural def siae_count_annotated_with_link(self, tender): url = reverse("admin:siaes_siae_changelist") + f"?tenders__in={tender.id}"