diff --git a/lemarche/tenders/admin.py b/lemarche/tenders/admin.py index cd25c32ff..ae6929234 100644 --- a/lemarche/tenders/admin.py +++ b/lemarche/tenders/admin.py @@ -132,28 +132,16 @@ def clean(self): @admin.register(Tender, site=admin_site) class TenderAdmin(FieldsetsInlineMixin, admin.ModelAdmin): list_display = [ - "id", - "status", - "is_validated_or_sent", - "title", - "author_with_link", - "author_kind_detail", + "title_with_link", "kind", - "deadline_date", - "start_working_date", - "siae_count_annotated_with_link", - # "siae_email_send_count_annotated_with_link", - "siae_email_link_click_count_annotated_with_link", - "siae_detail_display_count_annotated_with_link", - # "siae_email_link_click_or_detail_display_count_annotated_with_link", - "siae_detail_contact_click_count_annotated_with_link", - "siae_detail_cocontracting_click_count_annotated_with_link", - "siae_transactioned", - "created_at", - "validated_at", - "first_sent_at", - "limit_send_to_siae_batch", - "limit_nb_siae_interested", + "amount_display", + "location_in_list", + "distance_location_in_list", + "deadline_date_in_list", + "start_working_date_in_list", + "siae_count_annotated_with_link_in_list", + "siae_detail_contact_click_count_annotated_with_link_in_list", + "is_validated_or_sent", ] list_filter = [ @@ -429,7 +417,7 @@ def is_validated_or_sent(self, tender: Tender): return tender.is_validated_or_sent is_validated_or_sent.boolean = True - is_validated_or_sent.short_description = "Validé / Envoyé" + is_validated_or_sent.short_description = "Valider" def question_count_with_link(self, tender): url = reverse("admin:tenders_tenderquestion_changelist") + f"?tender__in={tender.id}" @@ -437,12 +425,42 @@ def question_count_with_link(self, tender): question_count_with_link.short_description = TenderQuestion._meta.verbose_name_plural - def author_with_link(self, tender): - url = reverse("admin:users_user_change", args=[tender.author_id]) - return format_html(f'{tender.author}') + def title_with_link(self, tender): + url = reverse("admin:tenders_tender_change", args=[tender.id]) + return format_html(f'{tender.title}') + + title_with_link.short_description = "Titre du besoin" + title_with_link.admin_order_field = "title" - author_with_link.short_description = "Client" - author_with_link.admin_order_field = "author" + def amount_display(self, tender): + return tender.amount_admin_display + + amount_display.short_description = "Budget" + amount_display.admin_order_field = "amount_exact" + + def location_in_list(self, tender): + return tender.location + + location_in_list.short_description = "Lieu d'inter" + location_in_list.admin_order_field = "location" + + def distance_location_in_list(self, tender): + return tender.distance_location + + distance_location_in_list.short_description = "Dist. d'inter" + distance_location_in_list.admin_order_field = "distance_location" + + def deadline_date_in_list(self, tender): + return tender.deadline_date + + deadline_date_in_list.short_description = "Clôture" + deadline_date_in_list.admin_order_field = "deadline_date" + + def start_working_date_in_list(self, tender): + return tender.start_working_date + + start_working_date_in_list.short_description = "Début" + start_working_date_in_list.admin_order_field = "start_working_date" def author_kind_detail(self, tender): return tender.author.kind_detail_display @@ -462,7 +480,12 @@ def siae_count_annotated_with_link(self, tender): return format_html(f'{getattr(tender, "siae_count_annotated", 0)}') siae_count_annotated_with_link.short_description = "S. concernées" - siae_count_annotated_with_link.admin_order_field = "siae_count_annotated" + + def siae_count_annotated_with_link_in_list(self, tender): + return self.siae_count_annotated_with_link(tender) + + siae_count_annotated_with_link_in_list.short_description = "S. concer." + siae_count_annotated_with_link_in_list.admin_order_field = "siae_count_annotated" def siae_ai_count_annotated_with_link(self, tender): url = ( @@ -526,7 +549,14 @@ def siae_detail_contact_click_count_annotated_with_link(self, tender): return format_html(f'{getattr(tender, "siae_detail_contact_click_count_annotated", 0)}') siae_detail_contact_click_count_annotated_with_link.short_description = "S. intéressées" - siae_detail_contact_click_count_annotated_with_link.admin_order_field = "siae_detail_contact_click_count_annotated" + + def siae_detail_contact_click_count_annotated_with_link_in_list(self, tender): + return self.siae_detail_contact_click_count_annotated_with_link(tender) + + siae_detail_contact_click_count_annotated_with_link_in_list.short_description = "S. intér." + siae_detail_contact_click_count_annotated_with_link_in_list.admin_order_field = ( + "siae_detail_contact_click_count_annotated" + ) def siae_detail_cocontracting_click_count_annotated_with_link(self, tender): url = ( diff --git a/lemarche/tenders/models.py b/lemarche/tenders/models.py index 4e907f8a6..af4d9fa49 100644 --- a/lemarche/tenders/models.py +++ b/lemarche/tenders/models.py @@ -661,6 +661,10 @@ def amount_display(self) -> str: else: return "Non renseigné" + @cached_property + def amount_admin_display(self) -> str: + return f"{self.amount_exact} €" if self.amount_exact else self.get_amount_display() + def questions_list(self): return list(self.questions.values("id", "text"))