Skip to content

Commit

Permalink
feat(Utilisateurs): gérer le numéro de téléphone avec une librairie d…
Browse files Browse the repository at this point in the history
…édiée (#1215)
  • Loading branch information
raphodn committed May 21, 2024
1 parent 3aaa04f commit fab59b8
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 23 deletions.
3 changes: 3 additions & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
"formtools", # django-formtools (Multistep and preview forms)
"huey.contrib.djhuey", # huey (Async tasks)
"rest_framework", # djangorestframework
"phonenumber_field", # django-phonenumber-field
]

LOCAL_APPS = [
Expand Down Expand Up @@ -301,6 +302,8 @@

SITE_ID = 1

PHONENUMBER_DEFAULT_REGION = "FR"


# Emails
# ------------------------------------------------------------------------------
Expand Down
20 changes: 20 additions & 0 deletions lemarche/users/migrations/0034_alter_user_phone.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 4.2.13 on 2024-05-15 13:55

import phonenumber_field.modelfields
from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("users", "0033_user_brevo_contact_id"),
]

operations = [
migrations.AlterField(
model_name="user",
name="phone",
field=phonenumber_field.modelfields.PhoneNumberField(
blank=True, max_length=20, region=None, verbose_name="Téléphone"
),
),
]
3 changes: 2 additions & 1 deletion lemarche/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from django.dispatch import receiver
from django.forms.models import model_to_dict
from django.utils import timezone
from phonenumber_field.modelfields import PhoneNumberField

from lemarche.stats.models import StatsUser
from lemarche.users import constants as user_constants
Expand Down Expand Up @@ -165,7 +166,7 @@ class User(AbstractUser):
kind = models.CharField(
verbose_name="Type", max_length=20, choices=user_constants.KIND_CHOICES_WITH_ADMIN, blank=True
)
phone = models.CharField(verbose_name="Téléphone", max_length=20, blank=True)
phone = PhoneNumberField(verbose_name="Téléphone", max_length=20, blank=True)

company = models.ForeignKey(
"companies.Company",
Expand Down
8 changes: 4 additions & 4 deletions lemarche/www/auth/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"id_kind": 0, # required
"first_name": "Prenom",
"last_name": "Nom",
"phone": "012345678", # not required
"phone": "+33123456789", # not required
# "company_name": "", # not asked here
"email": "siae@example.com",
"password1": "Erls92#32",
Expand All @@ -27,7 +27,7 @@
"id_kind": 1, # required
"first_name": "Prenom",
"last_name": "Nom",
"phone": "012345678",
"phone": "0123456789",
# "buyer_kind_detail": "PRIVATE_BIG_CORP",
"company_name": "Ma boite",
"position": "Role important",
Expand All @@ -44,7 +44,7 @@
"id_kind": 2, # required
"first_name": "Prenom",
"last_name": "Nom",
"phone": "012345678", # not required
"phone": "01 23 45 67 89", # not required
# "partner_kind": "RESEAU_IAE",
"company_name": "Ma boite",
"email": "partner@example.com",
Expand All @@ -58,7 +58,7 @@
"id_kind": 2, # required
"first_name": "Prenom",
"last_name": "Nom",
"phone": "012345678", # not required
"phone": "+33123456789", # not required
# "partner_kind": "RESEAU_IAE",
"company_name": "Ma boite",
"email": "partner2@example.com",
Expand Down
43 changes: 31 additions & 12 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ tiktoken = "^0.5.2"
wagtail = "^5.1.3"
whitenoise = "^6.6.0"
xlwt = "^1.3.0"
django-phonenumber-field = {extras = ["phonenumbers"], version = "^7.3.0"}

[tool.poetry.group.dev.dependencies]
black = "^23.12.1"
Expand Down
11 changes: 7 additions & 4 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ async-timeout==4.0.3 ; python_full_version >= "3.10.4" and python_version < "3.1
attrs==23.2.0 ; python_full_version >= "3.10.4" and python_version < "4.0"
beautifulsoup4==4.11.2 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
black==23.12.1 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
boto3==1.34.103 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
boto3==1.34.104 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
boto==2.49.0 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
botocore==1.34.103 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
botocore==1.34.104 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
certifi==2024.2.2 ; python_full_version >= "3.10.4" and python_version < "4"
cffi==1.16.0 ; os_name == "nt" and implementation_name != "pypy" and python_full_version >= "3.10.4" and python_full_version < "4.0.0"
cfgv==3.4.0 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
Expand Down Expand Up @@ -42,6 +42,7 @@ django-js-asset==2.2.0 ; python_full_version >= "3.10.4" and python_full_version
django-libsass==0.9 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
django-modelcluster==6.3 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
django-permissionedforms==0.1 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
django-phonenumber-field[phonenumbers]==7.3.0 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
django-select2==7.11.1 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
django-sesame==3.2.2 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
django-storages==1.14.3 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
Expand All @@ -59,10 +60,11 @@ et-xmlfile==1.1.0 ; python_full_version >= "3.10.4" and python_full_version < "4
exceptiongroup==1.2.1 ; python_full_version >= "3.10.4" and python_version < "3.11"
executing==2.0.1 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
factory-boy==3.3.0 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
faker==25.1.0 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
faker==25.2.0 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
filelock==3.14.0 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
filetype==1.2.0 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
flake8==6.1.0 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
freezegun==1.5.1 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
frozenlist==1.4.1 ; python_full_version >= "3.10.4" and python_version < "4.0"
greenlet==3.0.3 ; python_full_version >= "3.10.4" and python_version < "4.0" and (platform_machine == "win32" or platform_machine == "WIN32" or platform_machine == "AMD64" or platform_machine == "amd64" or platform_machine == "x86_64" or platform_machine == "ppc64le" or platform_machine == "aarch64")
h11==0.14.0 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
Expand Down Expand Up @@ -105,6 +107,7 @@ parso==0.8.4 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
pastel==0.2.1 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
pathspec==0.12.1 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
pexpect==4.9.0 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0" and (sys_platform != "win32" and sys_platform != "emscripten")
phonenumbers==8.13.36 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
pillow-heif==0.16.0 ; python_full_version < "4.0.0" and python_full_version >= "3.10.4"
pillow==10.3.0 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
platformdirs==4.2.1 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
Expand Down Expand Up @@ -165,7 +168,7 @@ tzdata==2024.1 ; python_full_version >= "3.10.4" and python_full_version < "4.0.
uritemplate==4.1.1 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
urllib3==2.2.1 ; python_full_version >= "3.10.4" and python_version < "4"
urllib3[socks]==2.2.1 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
virtualenv==20.26.1 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
virtualenv==20.26.2 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
wagtail==5.1.3 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
wcwidth==0.2.13 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
webencodings==0.5.1 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
Expand Down
6 changes: 4 additions & 2 deletions requirements/staging.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ asttokens==2.4.1 ; python_full_version >= "3.10.4" and python_full_version < "4.
async-timeout==4.0.3 ; python_full_version >= "3.10.4" and python_version < "3.11"
attrs==23.2.0 ; python_full_version >= "3.10.4" and python_version < "4.0"
beautifulsoup4==4.11.2 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
boto3==1.34.103 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
boto3==1.34.104 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
boto==2.49.0 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
botocore==1.34.103 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
botocore==1.34.104 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
certifi==2024.2.2 ; python_full_version >= "3.10.4" and python_version < "4"
charset-normalizer==3.3.2 ; python_full_version >= "3.10.4" and python_version < "4.0"
colorama==0.4.6 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0" and (sys_platform == "win32" or platform_system == "Windows")
Expand All @@ -35,6 +35,7 @@ django-js-asset==2.2.0 ; python_full_version >= "3.10.4" and python_full_version
django-libsass==0.9 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
django-modelcluster==6.3 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
django-permissionedforms==0.1 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
django-phonenumber-field[phonenumbers]==7.3.0 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
django-select2==7.11.1 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
django-sesame==3.2.2 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
django-storages==1.14.3 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
Expand Down Expand Up @@ -84,6 +85,7 @@ orjson==3.10.3 ; python_full_version >= "3.10.4" and python_version < "4.0"
packaging==23.2 ; python_full_version >= "3.10.4" and python_version < "4.0"
parso==0.8.4 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
pexpect==4.9.0 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0" and (sys_platform != "win32" and sys_platform != "emscripten")
phonenumbers==8.13.36 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
pillow-heif==0.16.0 ; python_full_version < "4.0.0" and python_full_version >= "3.10.4"
pillow==10.3.0 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
prompt-toolkit==3.0.43 ; python_full_version >= "3.10.4" and python_full_version < "4.0.0"
Expand Down

0 comments on commit fab59b8

Please sign in to comment.