Skip to content

Conversation

@meyerlor
Copy link

@meyerlor meyerlor commented Dec 1, 2025

Sorry for double PR, renamed my branch and was not aware this would delete the original PR.

Implements access control configuration for DXF export functionality in the QGIS plugin. This allows administrators to restrict DXF export by user groups and configure which WFS layers are exportable.

To test the plugin, you can download it here

Features:

  • Global "Allow DXF export" checkbox to enable/disable the feature
  • "Allowed groups" field for comma-separated Lizmap group IDs
  • Auto-populated table of all WFS-enabled layers with individual enable/disable checkboxes
  • Custom DXF export icon in navigation panel
  • Full CFG file save/load support with backward compatibility

Implementation:

  • Created dedicated DXF Export panel (lizmap/resources/ui/ui_form_dxf_export.ui)
  • Added DxfExportDefinitions for configuration schema
  • Implemented TableManagerDxfExport for WFS layer management
  • Registered global options (dxfExportEnabled, allowedGroups) in config.py
  • Added icon resources (19-dxfexport-dark.png, 19-dxfexport-white.png)
  • Connected UI widgets to save/load framework

The configuration is stored in the .qgs.cfg file as:

  • options.dxfExportEnabled (boolean, default: false)
  • options.allowedGroups (string, comma-separated group IDs)
  • dxfExport.layers[] (array of {layerId, enabled} objects)

Backward compatibility is ensured:

  • Old CFG files without these keys use safe defaults (disabled)
  • DXF export is disabled by default for existing projects
  • Empty allowedGroups means all users are allowed (when enabled)

Note: This only implements the configuration UI in the plugin. Access control
enforcement in lizmap-web-client will be implemented separately.

Working plugin with the changes included:
grafik

Example parts of the .qgs.cfg:

    "options": {
        "projection": {
            "proj4": "+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs",
            "ref": "EPSG:25832"
        },
        "bbox": [
            "509381.00309999997261912",
            "5279935.23770000040531158",
            "544169.05689999996684492",
            "5303809.39219999965280294"
        ],
        "mapScales": [
            10000,
            25000,
            50000,
            100000,
            250000,
            500000
        ],
        "minScale": 1,
        "maxScale": 1000000000,
        "use_native_zoom_levels": false,
        "hide_numeric_scale_value": false,
        "initialExtent": [
            509381.0031,
            5279935.2377,
            544169.0569,
            5303809.3922
        ],
        "popupLocation": "dock",
        "pointTolerance": 25,
        "lineTolerance": 10,
        "polygonTolerance": 5,
        "automatic_permalink": true,
        "tmTimeFrameSize": 10,
        "tmTimeFrameType": "seconds",
        "tmAnimationFrameLength": 1000,
        "datavizLocation": "dock",
        "theme": "dark",
        "fixed_scale_overview_map": true,
        "dxfExportEnabled": true,
        "allowedGroups": "admins,publishers",
        "dataviz_drag_drop": [],
        "default_background_color_index": 9

Two layer's config example:

        "Skizzen_Punkte": {
            "id": "Skizzen_Punkte_9d9588dc_6db2_435c_9c99_8762a61b5b20",
            "name": "Skizzen_Punkte",
            "type": "layer",
            "geometryType": "point",
            "extent": [
                533969.2096999998,
                5286065.003134375,
                533969.2096999998,
                5286065.003134375
            ],
            "crs": "EPSG:25832",
            "title": "Skizzen_Punkte",
            "abstract": "",
            "link": "",
            "minScale": 1,
            "maxScale": 1000000000000,
            "toggled": "False",
            "popup": "False",
            "popupSource": "auto",
            "popupTemplate": "",
            "popupMaxFeatures": 10,
            "children_lizmap_features_table": true,
            "popupDisplayChildren": "False",
            "popup_allow_download": true,
            "legend_image_option": "hide_at_startup",
            "groupAsLayer": "False",
            "baseLayer": "False",
            "displayInLegend": "True",
            "group_visibility": [],
            "singleTile": "True",
            "imageFormat": "image/png",
            "cached": "False",
            "clientCacheExpiration": 300,
            "dxfExportEnabled": true
        },
        "Skizzen_Linien": {
            "id": "Skizzen_Linien_34e06de2_adf7_4402_a524_0e58bfdf3436",
            "name": "Skizzen_Linien",
            "type": "layer",
            "geometryType": "line",
            "extent": [
                522999.84375,
                5285054.0,
                528079.875,
                5287674.0
            ],
            "crs": "EPSG:25832",
            "title": "Skizzen_Linien",
            "abstract": "",
            "link": "",
            "minScale": 1,
            "maxScale": 1000000000000,
            "toggled": "False",
            "popup": "False",
            "popupSource": "auto",
            "popupTemplate": "",
            "popupMaxFeatures": 10,
            "children_lizmap_features_table": true,
            "popupDisplayChildren": "False",
            "popup_allow_download": true,
            "legend_image_option": "hide_at_startup",
            "groupAsLayer": "False",
            "baseLayer": "False",
            "displayInLegend": "True",
            "group_visibility": [],
            "singleTile": "True",
            "imageFormat": "image/png",
            "cached": "False",
            "clientCacheExpiration": 300,
            "dxfExportEnabled": false
        },

@rldhont
Copy link
Contributor

rldhont commented Dec 1, 2025

Hi @meyerlor,

Thanks for your contribution. We have update the code for configuration, sorry for that.
Can you rebase and update your PR ? Thanks.

Fixes two bugs in LwcVersions class that were discovered during development:

- Add missing return statement in LwcVersions.oldest() method
- Fix LwcVersions.find() call in version_checker.py by removing the
  is_dev parameter (method signature was changed but call site wasn't updated)

Also updates .gitignore to exclude all .zip files, not just lizmap.*.zip pattern.
Implements access control configuration for DXF export functionality in the
QGIS plugin. This allows administrators to restrict DXF export by user groups
and configure which WFS layers are exportable.

Features:
- Global "Allow DXF export" checkbox to enable/disable the feature
- "Allowed groups" field for comma-separated Lizmap group IDs
- Auto-populated table of all WFS-enabled layers with individual enable/disable checkboxes
- Custom DXF export icon in navigation panel
- Full CFG file save/load support with backward compatibility

Implementation:
- Created dedicated DXF Export panel (lizmap/resources/ui/ui_form_dxf_export.ui)
- Added DxfExportDefinitions for configuration schema
- Implemented TableManagerDxfExport for WFS layer management
- Registered global options (dxfExportEnabled, allowedGroups) in config.py
- Added icon resources (19-dxfexport-dark.png, 19-dxfexport-white.png)
- Connected UI widgets to save/load framework

The configuration is stored in the .qgs.cfg file as:
- options.dxfExportEnabled (boolean, default: false)
- options.allowedGroups (string, comma-separated group IDs)
- dxfExport.layers[] (array of {layerId, enabled} objects)

Backward compatibility is ensured:
- Old CFG files without these keys use safe defaults (disabled)
- DXF export is disabled by default for existing projects
- Empty allowedGroups means all users are allowed (when enabled)

Note: This only implements the configuration UI in the plugin. Access control
enforcement in lizmap-web-client will be implemented separately.
@meyerlor meyerlor force-pushed the feature/dxf-export+access-control branch from 1266d79 to e782286 Compare December 1, 2025 14:39
@meyerlor
Copy link
Author

meyerlor commented Dec 1, 2025

@rldhont no problem! I rebased - should be ok now i think. Local tests were passing!

- Remove unused imports (QLabel, DxfExportDefinitions, DxfExportEditionDialog)
- Remove unused QWebSettings imports in WebKit fallback blocks
- Move module-level imports before WebKit detection blocks
- Fix import ordering (alphabetize standard library imports)
- Remove trailing whitespace
- Remove whitespace from blank lines
- Replace try-except-pass with contextlib.suppress
- Replace unnecessary elif with if after return statement
Update DXF export code to use the existing ambiguous_to_bool function
instead of creating a new to_bool alias. This is cleaner and uses the
established API.

Changes:
- lizmap/table_manager/dxf_export.py: Use ambiguous_to_bool
- tests/test_dxf_export.py: Update tests to use ambiguous_to_bool

Fixes ImportError in test_dxf_export.py and plugin.py.
@meyerlor meyerlor force-pushed the feature/dxf-export+access-control branch from 73ddd40 to 6088f6b Compare December 1, 2025 18:29
@dmarteau dmarteau force-pushed the master branch 3 times, most recently from 0e9c376 to 73662c6 Compare January 2, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants