Fixed #21021 -- Changed BaseGeometryWidget's default geometry type to 'Geometry'.
This commit is contained in:
parent
9175a2cc32
commit
7603036bd0
|
@ -61,11 +61,12 @@ class BaseGeometryWidget(Widget):
|
||||||
value.srid, self.map_srid, err
|
value.srid, self.map_srid, err
|
||||||
)
|
)
|
||||||
|
|
||||||
|
geom_type = gdal.OGRGeomType(self.attrs['geom_type']).name
|
||||||
context.update(self.build_attrs(self.attrs, {
|
context.update(self.build_attrs(self.attrs, {
|
||||||
'name': name,
|
'name': name,
|
||||||
'module': 'geodjango_%s' % name.replace('-', '_'), # JS-safe
|
'module': 'geodjango_%s' % name.replace('-', '_'), # JS-safe
|
||||||
'serialized': self.serialize(value),
|
'serialized': self.serialize(value),
|
||||||
'geom_type': gdal.OGRGeomType(self.attrs['geom_type']),
|
'geom_type': 'Geometry' if geom_type == 'Unknown' else geom_type,
|
||||||
'STATIC_URL': settings.STATIC_URL,
|
'STATIC_URL': settings.STATIC_URL,
|
||||||
'LANGUAGE_BIDI': translation.get_language_bidi(),
|
'LANGUAGE_BIDI': translation.get_language_bidi(),
|
||||||
**(attrs or {}),
|
**(attrs or {}),
|
||||||
|
|
|
@ -133,7 +133,7 @@ ol.inherits(GeometryTypeControl, ol.control.Control);
|
||||||
|
|
||||||
// Initialize the draw interaction
|
// Initialize the draw interaction
|
||||||
let geomType = this.options.geom_name;
|
let geomType = this.options.geom_name;
|
||||||
if (geomType === "Unknown" || geomType === "GeometryCollection") {
|
if (geomType === "Geometry" || geomType === "GeometryCollection") {
|
||||||
// Default to Point, but create icons to switch type
|
// Default to Point, but create icons to switch type
|
||||||
geomType = "Point";
|
geomType = "Point";
|
||||||
this.currentGeometryType = new GeometryTypeControl({widget: this, type: "Point", active: true});
|
this.currentGeometryType = new GeometryTypeControl({widget: this, type: "Point", active: true});
|
||||||
|
|
|
@ -382,6 +382,10 @@ class GeometryWidgetTests(SimpleTestCase):
|
||||||
widget = BaseGeometryWidget(attrs={'geom_type': 'POLYGON'})
|
widget = BaseGeometryWidget(attrs={'geom_type': 'POLYGON'})
|
||||||
context = widget.get_context('polygon', None, None)
|
context = widget.get_context('polygon', None, None)
|
||||||
self.assertEqual(context['geom_type'], 'Polygon')
|
self.assertEqual(context['geom_type'], 'Polygon')
|
||||||
|
# Widget.get_context() returns 'Geometry' instead of 'Unknown'.
|
||||||
|
widget = BaseGeometryWidget(attrs={'geom_type': 'GEOMETRY'})
|
||||||
|
context = widget.get_context('geometry', None, None)
|
||||||
|
self.assertEqual(context['geom_type'], 'Geometry')
|
||||||
|
|
||||||
def test_subwidgets(self):
|
def test_subwidgets(self):
|
||||||
widget = forms.BaseGeometryWidget()
|
widget = forms.BaseGeometryWidget()
|
||||||
|
|
Loading…
Reference in New Issue