From 9093bbc69b8db261cd01c4527f377bfb005899f1 Mon Sep 17 00:00:00 2001 From: Raruto Date: Fri, 3 May 2024 10:09:23 +0200 Subject: [PATCH] closes: https://github.com/g3w-suite/g3w-admin/issues/372 --- g3w-admin/client/api/views.py | 2 +- g3w-admin/client/tests/test_api.py | 44 +++++++++++++++--------------- g3w-admin/client/views.py | 3 +- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/g3w-admin/client/api/views.py b/g3w-admin/client/api/views.py index 0f091e607..6d823132a 100644 --- a/g3w-admin/client/api/views.py +++ b/g3w-admin/client/api/views.py @@ -125,11 +125,11 @@ def get( "rasterurl": settings.RASTER_URL, "proxyurl": reverse("interface-proxy"), "interfaceowsurl": reverse("interface-ows"), - "group": groupSerializer.data, "g3wsuite_logo_img": settings.CLIENT_G3WSUITE_LOGO, "credits": reverse("client-credits"), "main_map_title": generaldata.main_map_title, "i18n": settings.LANGUAGES, + **groupSerializer.data, } # add frontendurl if frontend is set diff --git a/g3w-admin/client/tests/test_api.py b/g3w-admin/client/tests/test_api.py index a9bc93f63..f5385e7b1 100644 --- a/g3w-admin/client/tests/test_api.py +++ b/g3w-admin/client/tests/test_api.py @@ -127,39 +127,39 @@ def testGroupConfigApiView(self): response = self._testApiCall('group-map-config', ['gruppo-1', 'qdjango', '1']) resp = json.loads(response.content) self.assertEqual(resp["vectorurl"], "/vector/api/") - self.assertEqual(resp["group"]["crs"], { + self.assertEqual(resp["crs"], { 'epsg': 4326, 'proj4': '+proj=longlat +datum=WGS84 +no_defs', 'geographic': True, 'axisinverted': True, 'extent': [-180.0, -90.0, 180.0, 90.0] }) - print(resp["group"]["mapcontrols"]) - self.assertEqual(resp["group"]["mapcontrols"], {'zoom': {}, 'zoombox': {}, 'zoomtoextent': {}, 'query': {}, 'querybbox': {}, 'querybypolygon': {}, 'overview': {}, 'scaleline': {}, 'geolocation': {}, 'streetview': {}, 'geocoding': {'providers': {}}, 'addlayers': {}, 'length': {}, 'area': {}, 'mouseposition': {}, 'scale': {}}) - self.assertEqual(resp["group"]["header_logo_img"], "logo_img/qgis-logo.png") - self.assertEqual(resp["group"]["name"], "Gruppo 1") - self.assertIsNone(resp["group"]["header_logo_link"]) - self.assertEqual(resp["group"]["initproject"], "qdjango:1") - self.assertEqual(resp["group"]["header_terms_of_use_link"], "") - self.assertTrue(resp["group"]["powered_by"]) - self.assertEqual(resp["group"]["baselayers"], [{'crs': {'epsg': 3857, 'proj4': '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs', 'geographic': False, 'axisinverted': False}, 'servertype': 'OSM', 'attribution': "OpenStreetMap contributors", 'name': 'OpenStreetMap', 'title': 'OSM', 'scalebasedvisibility': False, 'maxscale': 0, 'minscale': 100000000, 'id': 3, 'icon': None}]) - self.assertEqual(resp["group"]["header_terms_of_use_text"], "") - self.assertEqual(resp["group"]["header_custom_links"], []) - self.assertEqual(resp["group"]["background_color"], "#ffffff") - self.assertEqual(resp["group"]["id"], 1) - self.assertEqual(resp["group"]["slug"], 'gruppo-1') - self.assertEqual(len(resp["group"]["projects"]), 1) - - self.assertIn('vendorkeys', resp["group"]) - self.assertEqual(resp["group"]["vendorkeys"], {'google': '123456789'}) - - project = resp["group"]["projects"][0] + print(resp["mapcontrols"]) + self.assertEqual(resp["mapcontrols"], {'zoom': {}, 'zoombox': {}, 'zoomtoextent': {}, 'query': {}, 'querybbox': {}, 'querybypolygon': {}, 'overview': {}, 'scaleline': {}, 'geolocation': {}, 'streetview': {}, 'geocoding': {'providers': {}}, 'addlayers': {}, 'length': {}, 'area': {}, 'mouseposition': {}, 'scale': {}}) + self.assertEqual(resp["header_logo_img"], "logo_img/qgis-logo.png") + self.assertEqual(resp["name"], "Gruppo 1") + self.assertIsNone(resp["header_logo_link"]) + self.assertEqual(resp["initproject"], "qdjango:1") + self.assertEqual(resp["header_terms_of_use_link"], "") + self.assertTrue(resp["powered_by"]) + self.assertEqual(resp["baselayers"], [{'crs': {'epsg': 3857, 'proj4': '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs', 'geographic': False, 'axisinverted': False}, 'servertype': 'OSM', 'attribution': "OpenStreetMap contributors", 'name': 'OpenStreetMap', 'title': 'OSM', 'scalebasedvisibility': False, 'maxscale': 0, 'minscale': 100000000, 'id': 3, 'icon': None}]) + self.assertEqual(resp["header_terms_of_use_text"], "") + self.assertEqual(resp["header_custom_links"], []) + self.assertEqual(resp["background_color"], "#ffffff") + self.assertEqual(resp["id"], 1) + self.assertEqual(resp["slug"], 'gruppo-1') + self.assertEqual(len(resp["projects"]), 1) + + self.assertIn('vendorkeys', resp) + self.assertEqual(resp["vendorkeys"], {'google': '123456789'}) + + project = resp["projects"][0] to_compare = {'description': '

progetto 1

', 'title': 'Un progetto', 'thumbnail': '/fake/project.png', 'gid': 'qdjango:1', 'type': 'qdjango', 'id': 1} for k in list(to_compare.keys()): self.assertEqual(project[k], to_compare[k]) - self.assertIsNone(resp["group"]["overviewproject"]) + self.assertIsNone(resp["overviewproject"]) self.assertIsNone(resp["main_map_title"]) self.assertEqual(resp["mediaurl"], "/media/") self.assertFalse(resp["baseurl"].startswith('/'), 'baseurl is not an absolute URI') diff --git a/g3w-admin/client/views.py b/g3w-admin/client/views.py index 59ef2a644..7113d7645 100644 --- a/g3w-admin/client/views.py +++ b/g3w-admin/client/views.py @@ -145,7 +145,6 @@ def get_context_data(self, **kwargs): 'admin_url': reverse('home') } if (u in get_users_for_object(self.project, "change_project", with_group_users=True) or u.is_superuser) and reverse('home') else {}) }, - "group": deepcopy(groupSerializer.data), "baseurl": baseurl, "vectorurl": settings.VECTOR_URL, "proxyurl": reverse('interface-proxy'), @@ -156,6 +155,8 @@ def get_context_data(self, **kwargs): "credits": reverse('client-credits'), "version": get_version(), "frontendurl": baseurl if settings.FRONTEND else '', + # project data + **deepcopy(groupSerializer.data) }).decode('UTF-8') + ';' # project by type(app)