Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Set as 'help' property qgis layer's field 'comment' property #608

Draft
wants to merge 4 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion g3w-admin/qdjango/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
1 change: 1 addition & 0 deletions g3w-admin/qdjango/utils/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions g3w-admin/qdjango/vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
Loading