From 283162c7496a42de7a792d3640d365282a5bf2e0 Mon Sep 17 00:00:00 2001 From: Raphael Odini Date: Mon, 20 Nov 2023 16:49:42 +0100 Subject: [PATCH 1/2] User.buyer_kind_detail: rename values display fields --- ...1_user_rename_buyer_kind_detail_display.py | 31 +++++++++++++++++++ lemarche/users/models.py | 24 +++++++------- 2 files changed, 43 insertions(+), 12 deletions(-) create mode 100644 lemarche/users/migrations/0031_user_rename_buyer_kind_detail_display.py diff --git a/lemarche/users/migrations/0031_user_rename_buyer_kind_detail_display.py b/lemarche/users/migrations/0031_user_rename_buyer_kind_detail_display.py new file mode 100644 index 000000000..1ed656739 --- /dev/null +++ b/lemarche/users/migrations/0031_user_rename_buyer_kind_detail_display.py @@ -0,0 +1,31 @@ +# Generated by Django 4.2.2 on 2023-11-20 15:47 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("users", "0030_user_sectors"), + ] + + operations = [ + migrations.AlterField( + model_name="user", + name="buyer_kind_detail", + field=models.CharField( + blank=True, + choices=[ + ("PRIVATE_BIG_CORP", "Grand groupe (+5000 salariés)"), + ("PRIVATE_ETI", "ETI (+250 salariés)"), + ("PRIVATE_PME", "PME (+10 salariés)"), + ("PRIVATE_TPE", "TPE"), + ("PUBLIC_ASSOCIATION", "Association"), + ("PUBLIC_COLLECTIVITY", "Collectivité"), + ("PUBLIC_ESTABLISHMENT", "Établissement public"), + ("PUBLIC_MINISTRY", "Ministère"), + ], + max_length=20, + verbose_name="Type d'acheteur (détail)", + ), + ), + ] diff --git a/lemarche/users/models.py b/lemarche/users/models.py index 21f9b8362..b17d64c16 100644 --- a/lemarche/users/models.py +++ b/lemarche/users/models.py @@ -145,23 +145,23 @@ class User(AbstractUser): (BUYER_KIND_PUBLIC, "Public"), (BUYER_KIND_PRIVATE, "Privé"), ) - BUYER_KIND_DETAIL_PUBLIC_MINISTRY = "PUBLIC_MINISTRY" - BUYER_KIND_DETAIL_PUBLIC_ESTABLISHMENT = "PUBLIC_ESTABLISHMENT" - BUYER_KIND_DETAIL_PUBLIC_COLLECTIVITY = "PUBLIC_COLLECTIVITY" - BUYER_KIND_DETAIL_PUBLIC_ASSOCIATION = "PUBLIC_ASSOCIATION" BUYER_KIND_DETAIL_PRIVATE_BIG_CORP = "PRIVATE_BIG_CORP" BUYER_KIND_DETAIL_PRIVATE_ETI = "PRIVATE_ETI" BUYER_KIND_DETAIL_PRIVATE_PME = "PRIVATE_PME" BUYER_KIND_DETAIL_PRIVATE_TPE = "PRIVATE_TPE" + BUYER_KIND_DETAIL_PUBLIC_ASSOCIATION = "PUBLIC_ASSOCIATION" + BUYER_KIND_DETAIL_PUBLIC_COLLECTIVITY = "PUBLIC_COLLECTIVITY" + BUYER_KIND_DETAIL_PUBLIC_ESTABLISHMENT = "PUBLIC_ESTABLISHMENT" + BUYER_KIND_DETAIL_PUBLIC_MINISTRY = "PUBLIC_MINISTRY" BUYER_KIND_DETAIL_CHOICES = ( - (BUYER_KIND_DETAIL_PUBLIC_MINISTRY, "Public : Ministère"), - (BUYER_KIND_DETAIL_PUBLIC_ESTABLISHMENT, "Public : Établissement public"), - (BUYER_KIND_DETAIL_PUBLIC_COLLECTIVITY, "Public : Collectivité"), - (BUYER_KIND_DETAIL_PUBLIC_ASSOCIATION, "Public : Association"), - (BUYER_KIND_DETAIL_PRIVATE_BIG_CORP, "Privé : Grand groupe"), - (BUYER_KIND_DETAIL_PRIVATE_ETI, "Privé : ETI"), - (BUYER_KIND_DETAIL_PRIVATE_PME, "Privé : PME"), - (BUYER_KIND_DETAIL_PRIVATE_TPE, "Privé : TPE"), + (BUYER_KIND_DETAIL_PRIVATE_BIG_CORP, "Grand groupe (+5000 salariés)"), + (BUYER_KIND_DETAIL_PRIVATE_ETI, "ETI (+250 salariés)"), + (BUYER_KIND_DETAIL_PRIVATE_PME, "PME (+10 salariés)"), + (BUYER_KIND_DETAIL_PRIVATE_TPE, "TPE"), + (BUYER_KIND_DETAIL_PUBLIC_ASSOCIATION, "Association"), + (BUYER_KIND_DETAIL_PUBLIC_COLLECTIVITY, "Collectivité"), + (BUYER_KIND_DETAIL_PUBLIC_ESTABLISHMENT, "Établissement public"), + (BUYER_KIND_DETAIL_PUBLIC_MINISTRY, "Ministère"), ) PARTNER_KIND_FACILITATOR = "FACILITATEUR" From db3908553c7c972274b786b58e18467c4b63e5ef Mon Sep 17 00:00:00 2001 From: Raphael Odini Date: Tue, 21 Nov 2023 10:17:24 +0100 Subject: [PATCH 2/2] Fix tests --- lemarche/users/models.py | 3 ++- lemarche/users/tests.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lemarche/users/models.py b/lemarche/users/models.py index b17d64c16..9b2147bab 100644 --- a/lemarche/users/models.py +++ b/lemarche/users/models.py @@ -376,7 +376,8 @@ def kind_detail_display(self): if self.kind: kind_detail_display_string += self.get_kind_display() if self.buyer_kind_detail: - kind_detail_display_string += f" : {self.get_buyer_kind_detail_display()}" + # remove parenthesis suffix + kind_detail_display_string += f" : {self.get_buyer_kind_detail_display().split(' (', 1)[0]}" elif self.partner_kind: kind_detail_display_string += f" : {self.get_partner_kind_display()}" return kind_detail_display_string diff --git a/lemarche/users/tests.py b/lemarche/users/tests.py index 17fabefe1..699c07654 100644 --- a/lemarche/users/tests.py +++ b/lemarche/users/tests.py @@ -38,7 +38,7 @@ def test_kind_detail_display(self): self.assertEqual(user_buyer.kind_detail_display, "Acheteur") self.assertEqual(user_partner.kind_detail_display, "Partenaire") self.assertEqual(user_buyer_public.kind_detail_display, "Acheteur") - self.assertEqual(user_buyer_private_pme.kind_detail_display, "Acheteur : Privé : PME") + self.assertEqual(user_buyer_private_pme.kind_detail_display, "Acheteur : PME") self.assertEqual( user_partner_facilitator.kind_detail_display, "Partenaire : Facilitateur des clauses sociales" )