def map_detail(request, mapid, template="maps/map_detail.html"): """ The view that show details of each map """ map_obj = _resolve_map(request, mapid, "maps.view_map", _PERMISSION_MSG_VIEW) map_obj.popular_count += 1 map_obj.save() config = map_obj.viewer_json() config = json.dumps(config) layers = MapLayer.objects.filter(map=map_obj.id) return render_to_response( template, RequestContext( request, { "config": config, "map": map_obj, "layers": layers, "permissions_json": json.dumps(_perms_info(map_obj, MAP_LEV_NAMES)), "documents": get_related_documents(map_obj), "ows": getattr(ogc_server_settings, "ows", ""), }, ), )
def map_detail(request, mapid, template='maps/map_detail.html'): ''' The view that show details of each map ''' map_obj = _resolve_map(request, mapid, 'maps.view_map', _PERMISSION_MSG_VIEW) map_obj.popular_count += 1 map_obj.save() config = map_obj.viewer_json() config = json.dumps(config) layers = MapLayer.objects.filter(map=map_obj.id) return render_to_response( template, RequestContext( request, { 'config': config, 'map': map_obj, 'layers': layers, 'permissions_json': json.dumps(_perms_info(map_obj, MAP_LEV_NAMES)), }))
def test_perms_info(self): """ Tests the perms_info function (which passes permissions to the response context). """ # Add test to test perms being sent to the front end. layer = Layer.objects.all()[0] perms_info = _perms_info(layer, LAYER_LEV_NAMES) # Ensure there is no group info for the layer object by default self.assertEqual(dict(), perms_info['groups']) # Add the foo group to the layer object groups layer.set_group_level(self.bar, Layer.LEVEL_READ) perms_info = _perms_info(layer, LAYER_LEV_NAMES) # Ensure foo is in the perms_info output self.assertDictEqual(perms_info['groups'], {u'bar': u'layer_readonly'})
def map_detail(request, mapid, template='maps/map_detail.html'): ''' The view that show details of each map ''' map_obj = _resolve_map(request, mapid, 'maps.view_map', _PERMISSION_MSG_VIEW) map_obj.popular_count += 1 map_obj.save() config = map_obj.viewer_json() config = json.dumps(config) layers = MapLayer.objects.filter(map=map_obj.id) return render_to_response(template, RequestContext(request, { 'config': config, 'map': map_obj, 'layers': layers, 'permissions_json': json.dumps(_perms_info(map_obj, MAP_LEV_NAMES)), }))
def service_detail(request, service_id): ''' This view shows the details of a service ''' service = get_object_or_404(Service,pk=service_id) layer_list = service.layers.all() service_list = service.service_set.all() service_paginator = Paginator(service_list, 25) # Show 25 services per page layer_paginator = Paginator(layer_list, 25) # Show 25 services per page page = request.GET.get('page') try: layers = layer_paginator.page(page) except PageNotAnInteger: # If page is not an integer, deliver first page. layers = layer_paginator.page(1) except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. layers = layer_paginator.page(layer_paginator.num_pages) try: services = service_paginator.page(page) except PageNotAnInteger: # If page is not an integer, deliver first page. services = service_paginator.page(1) except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. services = service_paginator.page(service_paginator.num_pages) return render_to_response("services/service_detail.html", RequestContext(request, { 'service': service, 'layers': layers, 'services' : services, 'permissions_json': json.dumps(_perms_info(service, SERVICE_LEV_NAMES)) }))