diff --git a/g3w-admin/qdjango/tests/test_utils.py b/g3w-admin/qdjango/tests/test_utils.py index 7cd8b594e..0c1c732da 100644 --- a/g3w-admin/qdjango/tests/test_utils.py +++ b/g3w-admin/qdjango/tests/test_utils.py @@ -221,7 +221,7 @@ def test_layers(self): # check columns # -------------------------------------------------------- - columns_to_check = '[{"name": "ISOCODE", "type": "QSTRING", "label": "ISOCODE"}, {"name": "NAME_LOCAL", "type": "QSTRING", "label": "NAME_LOCAL"}, {"name": "NAME_EN", "type": "QSTRING", "label": "NAME_EN"}, {"name": "CAPITAL_EN", "type": "QSTRING", "label": "CAPITAL_EN"}, {"name": "NAME_DE", "type": "QSTRING", "label": "NAME_DE"}, {"name": "CAPITAL_DE", "type": "QSTRING", "label": "CAPITAL_DE"}, {"name": "NAME_IT", "type": "QSTRING", "label": "NAME_IT"}, {"name": "CAPITAL_IT", "type": "QSTRING", "label": "CAPITAL_IT"}, {"name": "NAME_FR", "type": "QSTRING", "label": "NAME_FR"}, {"name": "CAPITAL_FR", "type": "QSTRING", "label": "CAPITAL_FR"}, {"name": "NAME_BR", "type": "QSTRING", "label": "NAME_BR"}, {"name": "CAPITAL_BR", "type": "QSTRING", "label": "CAPITAL_BR"}, {"name": "NAME_ES", "type": "QSTRING", "label": "NAME_ES"}, {"name": "CAPITAL_ES", "type": "QSTRING", "label": "CAPITAL_ES"}, {"name": "POPULATION", "type": "QLONGLONG", "label": "POPULATION"}, {"name": "AREA_KM2", "type": "QLONGLONG", "label": "AREA_KM2"}, {"name": "ISO_NUM", "type": "INT", "label": "ISO_NUM"}]' + columns_to_check = '[{"name": "ISOCODE", "type": "QSTRING", "label": "ISOCODE", "comment": ""}, {"name": "NAME_LOCAL", "type": "QSTRING", "label": "NAME_LOCAL", "comment": ""}, {"name": "NAME_EN", "type": "QSTRING", "label": "NAME_EN", "comment": ""}, {"name": "CAPITAL_EN", "type": "QSTRING", "label": "CAPITAL_EN", "comment": ""}, {"name": "NAME_DE", "type": "QSTRING", "label": "NAME_DE", "comment": ""}, {"name": "CAPITAL_DE", "type": "QSTRING", "label": "CAPITAL_DE", "comment": ""}, {"name": "NAME_IT", "type": "QSTRING", "label": "NAME_IT", "comment": ""}, {"name": "CAPITAL_IT", "type": "QSTRING", "label": "CAPITAL_IT", "comment": ""}, {"name": "NAME_FR", "type": "QSTRING", "label": "NAME_FR", "comment": ""}, {"name": "CAPITAL_FR", "type": "QSTRING", "label": "CAPITAL_FR", "comment": ""}, {"name": "NAME_BR", "type": "QSTRING", "label": "NAME_BR", "comment": ""}, {"name": "CAPITAL_BR", "type": "QSTRING", "label": "CAPITAL_BR", "comment": ""}, {"name": "NAME_ES", "type": "QSTRING", "label": "NAME_ES", "comment": ""}, {"name": "CAPITAL_ES", "type": "QSTRING", "label": "CAPITAL_ES", "comment": ""}, {"name": "POPULATION", "type": "QLONGLONG", "label": "POPULATION", "comment": ""}, {"name": "AREA_KM2", "type": "QLONGLONG", "label": "AREA_KM2", "comment": ""}, {"name": "ISO_NUM", "type": "INT", "label": "ISO_NUM", "comment": ""}]' self.assertEqual(layer.columns, json.loads(columns_to_check)) diff --git a/g3w-admin/qdjango/utils/data.py b/g3w-admin/qdjango/utils/data.py index 635441e60..83c67902d 100644 --- a/g3w-admin/qdjango/utils/data.py +++ b/g3w-admin/qdjango/utils/data.py @@ -541,6 +541,7 @@ def _getDataColumns(self): 'name': f.name(), 'type': QVariant.typeToName(f.type()).upper() if QVariant.typeToName(f.type()) else None, 'label': f.displayName(), + 'comment': f.comment() }) return columns diff --git a/g3w-admin/qdjango/vector.py b/g3w-admin/qdjango/vector.py index 9124fc445..81fdc2567 100644 --- a/g3w-admin/qdjango/vector.py +++ b/g3w-admin/qdjango/vector.py @@ -313,6 +313,12 @@ def get_forms(self): fields[self.layer_name]['fields'][field] = { 'label': data['label']} + # If fields has a comment, set it as 'help' property + if 'comment' in data and data['comment']: + fields[self.layer_name]['fields'][field].update({ + "help": data["comment"] + }) + # add widgets if hasattr(self.layer, 'edittypes') and self.layer.edittypes: