Skip to content

Commit

Permalink
- Allow migrate_baseurl Managent Command being able to update GeoApps…
Browse files Browse the repository at this point in the history
… Data and MapStore Data blobs too
  • Loading branch information
afabiani committed Mar 9, 2022
1 parent 529c43d commit f7ed806
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions geonode/base/management/commands/migrate_baseurl.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def handle(self, **options):
_cnt = Map.objects.filter(thumbnail_url__icontains=source_address).update(
thumbnail_url=Func(
F('thumbnail_url'), Value(source_address), Value(target_address), function='replace'))
print(f"Updated {_cnt} Maps")
logger.info(f"Updated {_cnt} Maps")

_cnt = MapLayer.objects.filter(ows_url__icontains=source_address).update(
Expand All @@ -94,21 +95,25 @@ def handle(self, **options):
MapLayer.objects.filter(layer_params__icontains=source_address).update(
layer_params=Func(
F('layer_params'), Value(source_address), Value(target_address), function='replace'))
print(f"Updated {_cnt} MapLayers")
logger.info(f"Updated {_cnt} MapLayers")

_cnt = Layer.objects.filter(thumbnail_url__icontains=source_address).update(
thumbnail_url=Func(
F('thumbnail_url'), Value(source_address), Value(target_address), function='replace'))
print(f"Updated {_cnt} Layers")
logger.info(f"Updated {_cnt} Layers")

_cnt = Style.objects.filter(sld_url__icontains=source_address).update(
sld_url=Func(
F('sld_url'), Value(source_address), Value(target_address), function='replace'))
print(f"Updated {_cnt} Styles")
logger.info(f"Updated {_cnt} Styles")

_cnt = Link.objects.filter(url__icontains=source_address).update(
url=Func(
F('url'), Value(source_address), Value(target_address), function='replace'))
print(f"Updated {_cnt} Links")
logger.info(f"Updated {_cnt} Links")

_cnt = ResourceBase.objects.filter(thumbnail_url__icontains=source_address).update(
Expand All @@ -120,6 +125,7 @@ def handle(self, **options):
_cnt += ResourceBase.objects.filter(metadata_xml__icontains=source_address).update(
metadata_xml=Func(
F('metadata_xml'), Value(source_address), Value(target_address), function='replace'))
print(f"Updated {_cnt} ResourceBases")
logger.info(f"Updated {_cnt} ResourceBases")

_cnt = 0
Expand All @@ -130,6 +136,7 @@ def handle(self, **options):
GeoAppData.objects.filter(id=_app.id).update(blob=_blob)
_cnt += 1
finally:
print(f"Updated {_cnt} GeoAppDatas")
logger.info(f"Updated {_cnt} GeoAppDatas")

_cnt = 0
Expand All @@ -142,20 +149,23 @@ def handle(self, **options):
MapStoreData.objects.filter(id=_app.id).update(blob=_blob)
_cnt += 1
finally:
print(f"Updated {_cnt} MapStoreDatas")
logger.info(f"Updated {_cnt} MapStoreDatas")

site = Site.objects.get_current()
if site:
site.name = site.name.replace(source_address, target_address)
site.domain = site.domain.replace(source_address, target_address)
site.save()
print("Updated 1 Site")
logger.info("Updated 1 Site")

if check_ogc_backend(geoserver.BACKEND_PACKAGE):
if Application.objects.filter(name='GeoServer').exists():
_cnt = Application.objects.filter(name='GeoServer').update(
redirect_uris=Func(
F('redirect_uris'), Value(source_address), Value(target_address), function='replace'))
print(f"Updated {_cnt} OAUth2 Redirect URIs")
logger.info(f"Updated {_cnt} OAUth2 Redirect URIs")
finally:
print("...done!")

0 comments on commit f7ed806

Please sign in to comment.