Skip to content

Commit

Permalink
[Utilisateurs] Renommer les choix des types d'acheteurs (#983)
Browse files Browse the repository at this point in the history
* User.buyer_kind_detail: rename values display fields

* Fix tests
  • Loading branch information
raphodn authored Nov 23, 2023
1 parent e7fd885 commit cdb6895
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -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)",
),
),
]
27 changes: 14 additions & 13 deletions lemarche/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lemarche/users/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down

0 comments on commit cdb6895

Please sign in to comment.