Skip to content

Commit

Permalink
Merge branch 'main' into keep-querystring-in-assistant-links
Browse files Browse the repository at this point in the history
  • Loading branch information
fabienheureux authored Jan 15, 2025
2 parents f5a1cbf + 19d2ae2 commit 635c346
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ endif
PYTHON := .venv/bin/python
DJANGO_ADMIN := $(PYTHON) manage.py
PYTEST := $(PYTHON) -m pytest
DB_URL := postgres://qfdmo:qfdmo@localhost:6543/qfdmo # pragma: allowlist secret
DB_URL := postgres://qfdmo:qfdmo@localhost:6543/qfdmo# pragma: allowlist secret

# Makefile config
.PHONY: check
Expand Down Expand Up @@ -160,4 +160,4 @@ db-restore:
@DUMP_FILE=$$(find tmpbackup -type f -name "*.pgsql" -print -quit); \
pg_restore -d "$(DB_URL)" --clean --no-acl --no-owner --no-privileges "$$DUMP_FILE" || true
rm -rf tmpbackup
$(DJANGO_ADMIN) migrate
$(DJANGO_ADMIN) migrate
8 changes: 5 additions & 3 deletions qfdmo/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@ class ActeurSchema(ModelSchema):
..., alias="acteur_type", description="Le type d'acteur"
)
distance: Optional[float] = None

# (..., description="Distance en mètres")
nom: str = Field(..., alias="libelle", description="Le nom d'affichage de l'acteur")
adresse: str = Field(
..., alias="adresse_display", description="l'adresse complète de l'acteur"
)

@staticmethod
def resolve_distance(obj):
Expand All @@ -87,7 +89,7 @@ def resolve_distance(obj):

class Meta:
model = DisplayedActeur
fields = ["nom", "nom_commercial", "adresse", "identifiant_unique", "siret"]
fields = ["nom_commercial", "identifiant_unique", "siret"]


class ActeurFilterSchema(FilterSchema):
Expand Down
10 changes: 10 additions & 0 deletions qfdmo/models/acteur.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,16 @@ def sorted_acteur_services_libelles(self) -> list[str]:
.distinct()
)

@property
def adresse_display(self):
parts = []
fields = ["adresse", "adresse_complement", "code_postal", "ville"]
for field in fields:
if part := getattr(self, field):
parts.append(part)

return ", ".join(parts)

@cached_property
def acteur_services_display(self):
return ", ".join(self.sorted_acteur_services_libelles)
Expand Down

0 comments on commit 635c346

Please sign in to comment.