Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
dd656073
Kaydet (Commit)
dd656073
authored
Eyl 03, 2013
tarafından
Claude Paroz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #21003 -- Ensured geometry widget return value has SRID
Thanks Mathieu Leplatre for the report and initial patch.
üst
3550b27a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
12 deletions
+20
-12
fields.py
django/contrib/gis/forms/fields.py
+14
-11
widgets.py
django/contrib/gis/forms/widgets.py
+1
-1
test_geoforms.py
django/contrib/gis/tests/test_geoforms.py
+5
-0
No files found.
django/contrib/gis/forms/fields.py
Dosyayı görüntüle @
dd656073
...
@@ -41,10 +41,15 @@ class GeometryField(forms.Field):
...
@@ -41,10 +41,15 @@ class GeometryField(forms.Field):
"""
"""
if
value
in
self
.
empty_values
:
if
value
in
self
.
empty_values
:
return
None
return
None
try
:
return
GEOSGeometry
(
value
)
if
not
isinstance
(
value
,
GEOSGeometry
):
except
(
GEOSException
,
ValueError
,
TypeError
):
try
:
raise
forms
.
ValidationError
(
self
.
error_messages
[
'invalid_geom'
],
code
=
'invalid_geom'
)
value
=
GEOSGeometry
(
value
)
if
not
value
.
srid
:
value
.
srid
=
self
.
widget
.
map_srid
except
(
GEOSException
,
ValueError
,
TypeError
):
raise
forms
.
ValidationError
(
self
.
error_messages
[
'invalid_geom'
],
code
=
'invalid_geom'
)
return
value
def
clean
(
self
,
value
):
def
clean
(
self
,
value
):
"""
"""
...
@@ -77,16 +82,14 @@ class GeometryField(forms.Field):
...
@@ -77,16 +82,14 @@ class GeometryField(forms.Field):
def
_has_changed
(
self
,
initial
,
data
):
def
_has_changed
(
self
,
initial
,
data
):
""" Compare geographic value of data with its initial value. """
""" Compare geographic value of data with its initial value. """
# Ensure we are dealing with a geographic object
try
:
if
isinstance
(
initial
,
six
.
string_types
):
data
=
self
.
to_python
(
data
)
try
:
initial
=
self
.
to_python
(
initial
)
initial
=
GEOSGeometry
(
initial
)
except
ValidationError
:
except
(
GEOSException
,
ValueError
):
return
True
initial
=
None
# Only do a geographic comparison if both values are available
# Only do a geographic comparison if both values are available
if
initial
and
data
:
if
initial
and
data
:
data
=
fromstr
(
data
)
data
.
transform
(
initial
.
srid
)
data
.
transform
(
initial
.
srid
)
# If the initial value was not added by the browser, the geometry
# If the initial value was not added by the browser, the geometry
# provided may be slightly different, the first time it is saved.
# provided may be slightly different, the first time it is saved.
...
...
django/contrib/gis/forms/widgets.py
Dosyayı görüntüle @
dd656073
...
@@ -39,7 +39,7 @@ class BaseGeometryWidget(Widget):
...
@@ -39,7 +39,7 @@ class BaseGeometryWidget(Widget):
def
deserialize
(
self
,
value
):
def
deserialize
(
self
,
value
):
try
:
try
:
return
GEOSGeometry
(
value
)
return
GEOSGeometry
(
value
,
self
.
map_srid
)
except
(
GEOSException
,
ValueError
)
as
err
:
except
(
GEOSException
,
ValueError
)
as
err
:
logger
.
error
(
logger
.
error
(
"Error creating geometry from value '
%
s' (
%
s)"
%
(
"Error creating geometry from value '
%
s' (
%
s)"
%
(
...
...
django/contrib/gis/tests/test_geoforms.py
Dosyayı görüntüle @
dd656073
...
@@ -282,3 +282,8 @@ class CustomGeometryWidgetTest(SimpleTestCase):
...
@@ -282,3 +282,8 @@ class CustomGeometryWidgetTest(SimpleTestCase):
# Force deserialize use due to a string value
# Force deserialize use due to a string value
self
.
assertIn
(
escape
(
point
.
json
),
widget
.
render
(
'p'
,
point
.
json
))
self
.
assertIn
(
escape
(
point
.
json
),
widget
.
render
(
'p'
,
point
.
json
))
self
.
assertEqual
(
widget
.
deserialize_called
,
1
)
self
.
assertEqual
(
widget
.
deserialize_called
,
1
)
form
=
PointForm
(
data
=
{
'p'
:
point
.
json
})
self
.
assertTrue
(
form
.
is_valid
())
# Ensure that resulting geometry has srid set
self
.
assertEqual
(
form
.
cleaned_data
[
'p'
]
.
srid
,
4326
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment