Skip to content

Commit

Permalink
Merge branch 'dev' into Fix_issue_622
Browse files Browse the repository at this point in the history
# Conflicts:
#	g3w-admin/client/static/client/css/app.min.css
#	g3w-admin/client/static/client/js/app.min.js
#	g3w-admin/editing/static/editing/js/plugin.js
  • Loading branch information
wlorenzetti committed Oct 31, 2023
2 parents 24c4963 + d44c2b7 commit 91b33b5
Show file tree
Hide file tree
Showing 12 changed files with 401 additions and 452 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ Software releases follow theese main branches as described in the compatibility

| Branch | Python | Django | QGIS | [client] | First release | Status |
|------------|----------------|----------------|---------------|----------|---------------|----------------|
| [dev] | 3.10 | 3.2 | 3.28 | dev | Unreleased | ⚠️️ Unstable |
| [v.3.6.x] | 3.10 | 3.2 | 3.28 | 3.8.10 | May 2023 | 🪲️ Bug fixing |
| [v.3.5.x] | 3.10 | 2.2 | 3.22 | 3.7 | Nov 2022 | 🪲️ Bug fixing |
| [dev] | 3.10 | 3.2 | 3.28 | dev | Unreleased | ⚠️️ Unstable |
| [v.3.6.x] | 3.10 | 3.2 | 3.28 | 3.8.10 | May 2023 | 🪲️ Bug fixing |
| [v.3.5.x] | 3.10 | 2.2 | 3.22 | 3.7 | Nov 2022 | 🪲️ Bug fixing |
| [v.3.4.x] | 3.8 | 2.2 | 3.22 | 3.4 | Mar 2022 | 🚨 End of Life |
| [v.3.3.x] | 3.6 | 2.2 | 3.16 | 3.3 | Sep 2021 | 🚨 End of Life |
| [v.3.2.x] | 3.6 | 2.2 | 3.16 | 3.2 | Apr 2021 | 🚨 End of Life |
| [v.3.1.x] | 3.6 | 2.2 | 3.10 | 3.1 | Nov 2020 | 🚨 End of Life |
| [v.3.0.x] | 3.6 | 2.2 | 3.10 | 3.0 | Nov 2020 | 🚨 End of Life |
| [dj22-py3] | 3.6 | 2.2 | [🔗] | | | 🚨 End of Life |
| [py2] | 2.7 | 1.11 | [🔗] | | | 🚨 End of Life |
| [v.3.0.x] | 3.6 | 2.2 | 3.10 | 3.0 | Nov 2020 | 🚨 End of Life |
| [dj22-py3] | 3.6 | 2.2 | [🔗] | | | 🚨 End of Life |
| [py2] | 2.7 | 1.11 | [🔗] | | | 🚨 End of Life |

[dev]: https://github.com/g3w-suite/g3w-admin/tree/dev
[v.3.6.x]: https://github.com/g3w-suite/g3w-admin/tree/v.3.6.x
Expand Down
2 changes: 1 addition & 1 deletion g3w-admin/base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
logger.warning('Celery could not be imported, this might be ok if there are no custom suite modules that require Celery')


__version__ = (3, 6, 0, 'unstable', 0)
__version__ = (0, 0, 0, 'unstable', 0)
31 changes: 27 additions & 4 deletions g3w-admin/core/utils/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@


def editingFormField(fieldName, type=FIELD_TYPE_STRING, editable=True, required=False, validate=None,
fieldLabel=None, inputType=None, values=None, default_clause='', unique=False, expression='', pk=False, ** kwargs):
fieldLabel=None, inputType=None, values=None, default_clause='', unique=False, expression='',
pk=False, ** kwargs):
"""
Build editing form field for client.
"""
Expand Down Expand Up @@ -140,7 +141,7 @@ def editingFormField(fieldName, type=FIELD_TYPE_STRING, editable=True, required=

def mapLayerAttributes(layer, formField=False, **kwargs):
"""
Map database columns data from layer by type for client editing
Map database columns data from layer by type for client
"""

mappingData = FIELD_TYPES_MAPPING
Expand Down Expand Up @@ -222,6 +223,22 @@ def mapLayerAttributesFromQgisLayer(qgis_layer, **kwargs):

pk_attributes = qgis_layer.primaryKeyAttributes()

# Get available Join's fields
join_fields = {}
for order, join in enumerate(qgis_layer.vectorJoins()):
join_id = f'{qgis_layer.id()}_vectorjoin_{order}'
joinlayer_pk_attributes = join.joinLayer().primaryKeyAttributes()
for i, f in enumerate(join.joinLayer().fields()):
editable = join.isEditable()

# Check if referencing field is PK
if i in joinlayer_pk_attributes:
editable = False
join_fields[join.prefixedFieldName(f)] = {
'editable': editable,
'join_id': join_id}


# Determine if we are using an old and bugged version of QGIS
IS_QGIS_3_10 = Qgis.QGIS_VERSION.startswith('3.10')

Expand Down Expand Up @@ -282,8 +299,6 @@ def mapLayerAttributesFromQgisLayer(qgis_layer, **kwargs):
else:
is_pk = (field_index in pk_attributes)

#

toRes[field.name()] = editingFormField(
field.name(),
required=not_null,
Expand Down Expand Up @@ -342,6 +357,14 @@ def mapLayerAttributesFromQgisLayer(qgis_layer, **kwargs):
toRes[field.name()]['input']['options']['default_expression']['apply_on_update'] = True \
if field.defaultValueDefinition().applyOnUpdate() else False

# Check for Join's field.
# About joins in QGIS control the join settings for editing.
try:
toRes[field.name()]['vectorjoin_id'] = join_fields[field.name()]['join_id']
toRes[field.name()]["editable"] = join_fields[field.name()]["editable"]
except:
pass

field_index += 1

return toRes
Expand Down
Loading

0 comments on commit 91b33b5

Please sign in to comment.