Skip to content

Commit

Permalink
🗃️(dashboard) add new Entity fields
Browse files Browse the repository at this point in the history
Introduce additional fields to the Entity model, such as company type, legal form, trade name, SIRET, NAF, and address details.
Add the associated validators.
Update EntityFactory .
  • Loading branch information
ssorin committed Jan 23, 2025
1 parent 77d384c commit 3ef1b4b
Show file tree
Hide file tree
Showing 3 changed files with 166 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/dashboard/apps/core/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,26 @@ class EntityFactory(factory.django.DjangoModelFactory):
"""Factory class for creating instances of the Entity model."""

name = factory.Faker("company")
company_type = factory.Faker(
"random_element",
elements=[
"entreprise",
"collectivité locale",
"ECPI",
"Association",
"copropriété",
],
)
legal_form = factory.Faker(
"random_element", elements=["SA", "SARL", "SAS", "SCOP", "EI"]
)
trade_name = factory.Faker("company")
siret = factory.Faker("numerify", text="##############")
naf = factory.Faker("bothify", text="####?", letters="ABCDEFGHIJKLMNOPQRSTUVWXYZ")
address_1 = factory.Faker("street_address")
address_2 = factory.Faker("secondary_address")
address_zip_code = factory.Faker("postcode")
address_city = factory.Faker("city")

class Meta: # noqa: D106
model = Entity
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Generated by Django 5.1.5 on 2025-01-23 14:17

import apps.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
(
"qcd_core",
"0003_alter_deliverypoint_managers_alter_entity_proxy_for_and_more",
),
]

operations = [
migrations.AddField(
model_name="entity",
name="address_1",
field=models.CharField(
blank=True, max_length=255, null=True, verbose_name="address"
),
),
migrations.AddField(
model_name="entity",
name="address_2",
field=models.CharField(
blank=True, max_length=255, null=True, verbose_name="address complement"
),
),
migrations.AddField(
model_name="entity",
name="address_city",
field=models.CharField(
blank=True, max_length=255, null=True, verbose_name="city"
),
),
migrations.AddField(
model_name="entity",
name="address_zip_code",
field=models.CharField(
blank=True,
max_length=5,
null=True,
validators=[apps.core.validators.validate_zip_code],
verbose_name="zip code",
),
),
migrations.AddField(
model_name="entity",
name="company_type",
field=models.CharField(
blank=True,
help_text="entreprise/ collectivité locale, ECPI, Association, copropriété, ...",
max_length=255,
null=True,
verbose_name="type",
),
),
migrations.AddField(
model_name="entity",
name="legal_form",
field=models.CharField(
blank=True,
help_text="SA, SARL …",
max_length=50,
null=True,
verbose_name="legal form",
),
),
migrations.AddField(
model_name="entity",
name="naf",
field=models.CharField(
blank=True,
max_length=5,
null=True,
validators=[apps.core.validators.validate_naf_code],
verbose_name="NAF code",
),
),
migrations.AddField(
model_name="entity",
name="siret",
field=models.CharField(
blank=True,
max_length=14,
null=True,
validators=[apps.core.validators.validate_siret],
verbose_name="SIRET",
),
),
migrations.AddField(
model_name="entity",
name="trade_name",
field=models.CharField(
blank=True, max_length=255, null=True, verbose_name="trade name"
),
),
]
46 changes: 46 additions & 0 deletions src/dashboard/apps/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from .abstract_models import DashboardBase
from .managers import DeliveryPointManager
from .validators import validate_naf_code, validate_siret, validate_zip_code


class Entity(DashboardBase):
Expand All @@ -34,6 +35,51 @@ class Entity(DashboardBase):
symmetrical=False,
related_name="proxies",
)
company_type = models.CharField(
_("type"),
max_length=255,
help_text=_(
"entreprise/ collectivité locale, ECPI, Association, copropriété, ..."
),
blank=True,
null=True,
)
legal_form = models.CharField(
_("legal form"),
max_length=50,
help_text=_("SA, SARL …"),
blank=True,
null=True,
)
trade_name = models.CharField(
_("trade name"), max_length=255, blank=True, null=True
)
siret = models.CharField(
_("SIRET"),
max_length=14,
validators=[validate_siret],
blank=True,
null=True,
)
naf = models.CharField(
_("NAF code"),
validators=[validate_naf_code],
max_length=5,
blank=True,
null=True,
)
address_1 = models.CharField(_("address"), max_length=255, blank=True, null=True)
address_2 = models.CharField(
_("address complement"), max_length=255, blank=True, null=True
)
address_zip_code = models.CharField(
_("zip code"),
max_length=5,
validators=[validate_zip_code],
blank=True,
null=True,
)
address_city = models.CharField(_("city"), max_length=255, blank=True, null=True)

class Meta: # noqa: D106
verbose_name = "entity"
Expand Down

0 comments on commit 3ef1b4b

Please sign in to comment.