Skip to content

Commit

Permalink
Fix error when no bbox from GeoRepo (#297)
Browse files Browse the repository at this point in the history
  • Loading branch information
meomancer authored Aug 20, 2024
1 parent 87c97cc commit efa58c0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion django_project/_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.42.7
1.42.8
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function MapConfig() {
// Add history
useEffect(() => {
if (
referenceLayerData?.data?.bbox &&
referenceLayerData?.data?.bbox?.length &&
(
!prevState?.extent?.length ||
JSON.stringify(referenceLayerData?.data?.bbox) !== JSON.stringify(prevState?.extent)
Expand Down
16 changes: 10 additions & 6 deletions django_project/frontend/views/admin/dashboard/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,16 @@ class DashboardCreateViewBase:

def save(self, data, user, files):
"""Save data."""
data = DashboardForm.update_data(data)
if Dashboard.name_is_exist_of_all(data['slug']):
return HttpResponseBadRequest(
f'Dashboard with this url shortcode : {data["slug"]} '
f'is exist. Please choose other url shortcode.'
)
try:
data = DashboardForm.update_data(data)
if Dashboard.name_is_exist_of_all(data['slug']):
return HttpResponseBadRequest(
f'Dashboard with this url shortcode : {data["slug"]} '
f'is exist. Please choose other url shortcode.'
)
except ValueError as e:
return HttpResponseBadRequest(e)

# Get origin project
origin = None
origin_id = data.get('origin_id', None)
Expand Down
8 changes: 7 additions & 1 deletion django_project/geosight/data/forms/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,13 @@ def update_data(data):
other_data = data['data']

# save polygon
poly = Polygon.from_bbox(other_data['extent'])
try:
poly = Polygon.from_bbox(other_data['extent'])
except ValueError:
raise ValueError(
'Invalid extent, '
'it seems the extent from GeoRepo is empty or not correct.'
)
poly.srid = 4326
data['extent'] = poly

Expand Down

0 comments on commit efa58c0

Please sign in to comment.