summaryrefslogtreecommitdiff
path: root/archaeological_operations/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r--archaeological_operations/models.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py
index 301b9c6ca..48bdfb450 100644
--- a/archaeological_operations/models.py
+++ b/archaeological_operations/models.py
@@ -1040,9 +1040,10 @@ def get_values_town_related(item, prefix, values, filtr=None):
if not filtr or prefix + "towns_count" in filtr:
values[prefix + "towns_count"] = str(item.towns.count())
get_towns = not filtr or prefix + "towns" in filtr
+ get_towns_code = not filtr or prefix + "towns_code" in filtr
get_dpt = not filtr or prefix + "departments" in filtr
get_dpt_nb = not filtr or prefix + "departments_number" in filtr
- if not get_towns and not get_dpt and not get_dpt_nb:
+ if not get_towns and not get_dpt and not get_dpt_nb or not get_towns_code:
return values
if get_towns:
values[prefix + "towns"] = ""
@@ -1050,11 +1051,17 @@ def get_values_town_related(item, prefix, values, filtr=None):
values[prefix + "departments"] = ""
if get_dpt_nb:
values[prefix + "departments_number"] = ""
+ if get_towns_code:
+ values[prefix + "towns_code"] = ""
if item.towns.count():
if get_towns:
values[prefix + "towns"] = ", ".join(
[town.name for town in item.towns.all().order_by("name")]
)
+ if get_towns_code:
+ values[prefix + "towns_code"] = ", ".join(
+ [(town.numero_insee or "-") for town in item.towns.all().order_by("numero_insee")]
+ )
if settings.COUNTRY == "fr" and (get_dpt_nb or get_dpt_nb):
dpts_num = set([town.numero_insee[:2] for town in item.towns.all()])
if get_dpt_nb: