diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2024-06-13 16:54:19 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2024-06-19 14:42:32 +0200 |
commit | baa8b37fe683828cb2471f1616d5d8ad36e91920 (patch) | |
tree | 589787cfbb8428740b0be2afa1e73b99daa77a31 /docs/generate_values_doc.py | |
parent | b81a8233c9d905fd8cee50a68e4750d639f15308 (diff) | |
download | Ishtar-baa8b37fe683828cb2471f1616d5d8ad36e91920.tar.bz2 Ishtar-baa8b37fe683828cb2471f1616d5d8ad36e91920.zip |
🐛 documentation - add missing fields, sections in technical values, fix translations
Diffstat (limited to 'docs/generate_values_doc.py')
-rw-r--r-- | docs/generate_values_doc.py | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/docs/generate_values_doc.py b/docs/generate_values_doc.py index 6cd56ad83..dac4539b1 100644 --- a/docs/generate_values_doc.py +++ b/docs/generate_values_doc.py @@ -13,15 +13,15 @@ from ishtar_common.models_common import Address, GeoItem # TODO: à traduire -TYPES = { +TYPES = { # put more precise fields after generic field. e.g. IntegerField before PositiveIntegerField 'IntegerField': "Entier", 'PositiveIntegerField': "Entier positif", 'PositiveSmallIntegerField': "Entier positif", 'FloatField': "Nombre à virgule", 'TextField': "Texte", 'CharField': "Chaîne de caractères", - 'DateField': "Date", 'DateTimeField': "Date/heure", + 'DateField': "Date", 'EmailField': "Courriel", 'NullBooleanField': "Booléen", 'BooleanField': "Booléen", @@ -32,7 +32,8 @@ TYPES = { 'LineStringField': "Ligne", 'MultiPolygonField': "Multi-polygones", 'MultiPointField': "Multi-points", - 'MultiLineStringField': "Multi-lignes" + 'MultiLineStringField': "Multi-lignes", + "SlugField": "Chaîne de caractères", } TEMPLATES = ( @@ -55,20 +56,23 @@ EXCLUDED = [ "relation_dot", "relation_dot_above", "relation_dot_below", "relation_image_above", "relation_image_below", "auto_external_id", "history_date", "created", "cached_x", "cached_y", "cached_z", - "import_key", "departement", + "import_key", "departement", "timestamp_geo", "timestamp_label" ] EXCLUDED += ["parcel_owner"] # temporary MODELS = { "ishtar_common": ["person", "organization", "author", "document", "geovectordata", "area", "town"], "archaeological_operations": ["operation", "archaeologicalsite", - "parcel", "administrativeact"], - "archaeological_files": ["file"], - "archaeological_context_records": ["dating", "contextrecord"], - "archaeological_finds": ["basefind", "find", "treatment", "treatmentfile"], + "parcel", "administrativeact", "recordrelations"], + "archaeological_files": ["file", "preventivefilegroundjob", "preventivefilejob", + "preventivefileequipmentservicecost"], + "archaeological_context_records": ["dating", "contextrecord", "recordrelations"], + "archaeological_finds": ["basefind", "find", "findbasket", "treatment", "treatmentfile"], "archaeological_warehouse": ["warehouse", "container"], } +ADDRESS_EXCLUDED = ["person", "organization", "warehouse"] + lc = settings.LANGUAGE_CODE lc = lc[:2] + "_" + lc[-2:].upper() + ".UTF-8" locale.setlocale(locale.LC_ALL, lc) @@ -134,7 +138,6 @@ def get_values(tpl_model, model, excluded, model_types, messages): for model_class in model_types: if model_class in field_classes: type_desc = model_types[model_class] - break if getattr(field, "max_length", None): type_desc += " ({})".format(field.max_length) if not type_desc: @@ -170,20 +173,24 @@ for template_name, template_name_dest, language in TEMPLATES: address_values = get_values(tpl_model, Address, excluded=excluded, model_types=TYPES, messages=MESSAGES) render_dct["ishtar_common"]["address"] = address_values - excluded += address_values["fields"] + address_excluded = address_values["fields"] geo_values = get_values(tpl_model, GeoItem, excluded=excluded, model_types=TYPES, messages=MESSAGES) - #render_dct["ishtar_common"]["geoitem"] = geo_values - excluded += geo_values["fields"] + geo_excluded = geo_values["fields"] for app_name in MODELS: # print([m._meta.model_name # for m in apps.get_app_config(app_name).get_models()]) for model_name in MODELS[app_name]: model = apps.get_app_config(app_name).get_model(model_name) + exc = excluded[:] + if model_name != "geovectordata": + exc += geo_excluded + if model_name in ADDRESS_EXCLUDED: + exc += address_excluded render_dct[app_name][model_name] = get_values( - tpl_model, model, excluded, TYPES, messages=MESSAGES) + tpl_model, model, exc, TYPES, messages=MESSAGES) template_name = os.path.abspath( settings.ROOT_PATH + "../docs/" + template_name) |