Skip to content

Commit 6bdb806

Browse files
committed
fix(spp_gis): use dedicated geofence tag model instead of spp.vocabulary
The tag_ids field on spp.gis.geofence was pointing to spp.vocabulary, which is a generic vocabulary model containing all tag categories (Country, Currency, etc.). Replace with a dedicated spp.gis.geofence.tag model so the tags dropdown only shows geofence-specific tags.
1 parent d9476c6 commit 6bdb806

4 files changed

Lines changed: 22 additions & 13 deletions

File tree

spp_gis/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"license": "LGPL-3",
1212
"development_status": "Production/Stable",
1313
"maintainers": ["jeremi", "gonzalesedwin1123", "reichie020212"],
14-
"depends": ["base", "web", "contacts", "spp_security", "spp_area", "spp_vocabulary", "spp_registry"],
14+
"depends": ["base", "web", "contacts", "spp_security", "spp_area", "spp_registry"],
1515
"external_dependencies": {"python": ["shapely", "pyproj", "geojson"]},
1616
"data": [
1717
"data/res_config_data.xml",

spp_gis/models/geofence.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@
1515
_logger = logging.getLogger(__name__)
1616

1717

18+
class GisGeofenceTag(models.Model):
19+
"""Tags for classifying geofences."""
20+
21+
_name = "spp.gis.geofence.tag"
22+
_description = "Geofence Tag"
23+
_order = "name"
24+
25+
name = fields.Char(required=True, translate=True)
26+
color = fields.Integer(string="Color Index")
27+
active = fields.Boolean(default=True)
28+
29+
1830
class GisGeofence(models.Model):
1931
"""Saved Geographic Areas of Interest.
2032
@@ -63,7 +75,7 @@ class GisGeofence(models.Model):
6375

6476
# Tags for flexible classification
6577
tag_ids = fields.Many2many(
66-
"spp.vocabulary",
78+
"spp.gis.geofence.tag",
6779
"spp_gis_geofence_tag_rel",
6880
"geofence_id",
6981
"tag_id",

spp_gis/security/ir.model.access.csv

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ access_spp_raster_layer_admin,Raster Layer Admin,spp_gis.model_spp_gis_raster_la
66
access_spp_raster_layer_type_admin,Raster Layer Type Admin,spp_gis.model_spp_gis_raster_layer_type,spp_security.group_spp_admin,1,1,1,1
77
access_spp_data_layer_read,Data Layer Read,spp_gis.model_spp_gis_data_layer,spp_registry.group_registry_read,1,0,0,0
88
access_spp_raster_layer_read,Raster Layer Read,spp_gis.model_spp_gis_raster_layer,spp_registry.group_registry_read,1,0,0,0
9+
access_spp_gis_geofence_tag_admin,Geofence Tag Admin,spp_gis.model_spp_gis_geofence_tag,spp_security.group_spp_admin,1,1,1,1
10+
access_spp_gis_geofence_tag_manager,Geofence Tag Manager,spp_gis.model_spp_gis_geofence_tag,spp_registry.group_registry_manager,1,1,1,0
11+
access_spp_gis_geofence_tag_read,Geofence Tag Read,spp_gis.model_spp_gis_geofence_tag,spp_registry.group_registry_read,1,0,0,0
912
access_spp_gis_geofence_admin,Geofence Admin,spp_gis.model_spp_gis_geofence,spp_security.group_spp_admin,1,1,1,1
1013
access_spp_gis_geofence_manager,Geofence Manager,spp_gis.model_spp_gis_geofence,spp_registry.group_registry_manager,1,1,1,1
1114
access_spp_gis_geofence_officer,Geofence Officer,spp_gis.model_spp_gis_geofence,spp_registry.group_registry_officer,1,1,1,0

spp_gis/tests/test_geofence.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,12 @@ def setUpClass(cls):
6161
],
6262
}
6363

64-
# Create test vocabulary for tags
65-
cls.tag1 = cls.env["spp.vocabulary"].search(
66-
[("namespace_uri", "=", "urn:openspp:concept:geofence_tag_1")],
67-
limit=1,
64+
# Create test tag for geofences
65+
cls.tag1 = cls.env["spp.gis.geofence.tag"].create(
66+
{
67+
"name": "Test Tag 1",
68+
}
6869
)
69-
if not cls.tag1:
70-
cls.tag1 = cls.env["spp.vocabulary"].create(
71-
{
72-
"name": "Test Tag 1",
73-
"namespace_uri": "urn:openspp:concept:geofence_tag_1",
74-
}
75-
)
7670

7771
def test_create_geofence_basic(self):
7872
"""Test creating a basic geofence."""

0 commit comments

Comments
 (0)