def overview_permissions(request): """ Gives an overview of all permissions """ if not (request.user.is_staff): raise Http404 request_username = request.GET.get('user', None) if request_username is None: request_user = request.user else: request_user = User.objects.get(username=request_username) request_presentationlayer_id = request.GET.get('presentationlayer_id', None) if request_presentationlayer_id is None: request_presentationlayer = None text = 'Wat mag user "%s" uberhaupt voor dingen doen?' % request_user source_application_choices = ( PresentationLayer.SOURCE_APPLICATION_CHOICES) else: request_presentationlayer = PresentationLayer.objects.get( pk=int(request_presentationlayer_id)) text = ('Wat mag user "%s" dingen doen voor presentationlayer "%s".' % (request_user, str(request_presentationlayer))) source_application_choices = ( (request_presentationlayer.source_application, PresentationLayer.SOURCE_APPLICATION_DICT[ request_presentationlayer.source_application]), ) header = range(1, 11) permission_list = [] pm = PermissionManager(request_user) for app_code, app_name in source_application_choices: app_block = {} app_block['title'] = app_name app_block['header'] = header app_block['table'] = [] for permission in [ PermissionManager.PERMISSION_PRESENTATIONLAYER_VIEW, PermissionManager.PERMISSION_PRESENTATIONLAYER_EDIT ]: row = [PermissionManager.PERMISSION_DICT[permission]] for permission_level in header: row.append( pm.check_permission_app( app_code, permission_level, permission, presentationlayer=request_presentationlayer)) app_block['table'].append(row) permission_list.append(app_block) return render_to_response('presentation/overview_permissions.html', { 'permissions': permission_list, 'user': request.user, 'text': text, })
def overview_permissions(request): """ Gives an overview of all permissions """ if not(request.user.is_staff): raise Http404 request_username = request.GET.get('user', None) if request_username is None: request_user = request.user else: request_user = User.objects.get(username=request_username) request_presentationlayer_id = request.GET.get( 'presentationlayer_id', None) if request_presentationlayer_id is None: request_presentationlayer = None text = 'Wat mag user "%s" uberhaupt voor dingen doen?' % request_user source_application_choices = ( PresentationLayer.SOURCE_APPLICATION_CHOICES) else: request_presentationlayer = PresentationLayer.objects.get( pk=int(request_presentationlayer_id)) text = ('Wat mag user "%s" dingen doen voor presentationlayer "%s".' % (request_user, str(request_presentationlayer))) source_application_choices = ( (request_presentationlayer.source_application, PresentationLayer.SOURCE_APPLICATION_DICT[ request_presentationlayer.source_application]),) header = range(1, 11) permission_list = [] pm = PermissionManager(request_user) for app_code, app_name in source_application_choices: app_block = {} app_block['title'] = app_name app_block['header'] = header app_block['table'] = [] for permission in [ PermissionManager.PERMISSION_PRESENTATIONLAYER_VIEW, PermissionManager.PERMISSION_PRESENTATIONLAYER_EDIT]: row = [PermissionManager.PERMISSION_DICT[permission]] for permission_level in header: row.append( pm.check_permission_app( app_code, permission_level, permission, presentationlayer=request_presentationlayer)) app_block['table'].append(row) permission_list.append(app_block) return render_to_response('presentation/overview_permissions.html', {'permissions': permission_list, 'user': request.user, 'text': text, })
def service_get_presentationlayer_settings( request, pl_id): """get_settings of presentationlayer return: overlaytype: presentationtype_overlaytype - integer - (wms, map, general, (point, line)) type: presentationtype_valuetype - integer - (timeserie, classification, singlevalue, static) has_value_source (kan ik waarden of grafieken van een punt opvragen??) legend: array of legends with: id: name: in case of default: dtype (0=personal default, 1=project default, 2=presentationType default) in case of grid: extent (in original srid) - north, south, west,east srid nrrows nrcols gridsize in case of animation: firstnr (nr first timestep) startnr (where default starts the animation slider) lastnr (nr last timestep) dt (delta time between timesteps) in case of classification: firstnr (nr first class) startnr (default class, which is first showed when ) lastnr (nr last timestep) array of class boundaries voor resultaten met figuren, haalt afmetingen en extents op """ pl = get_object_or_404(PresentationLayer, pk=pl_id) pm = PermissionManager(request.user) if not pm.check_permission( pl, PermissionManager.PERMISSION_PRESENTATIONLAYER_VIEW): raise Http404 rec = {} if pl.presentationtype.geo_type == PresentationType.GEO_TYPE_GRID: try: pl.presentationgrid except PresentationGrid.DoesNotExist: return HttpResponse( simplejson.dumps({}), mimetype="application/json") rec['bounds'] = {} rec['bounds']['projection'] = pl.presentationgrid.bbox_orignal_srid extent = pl.presentationgrid.extent.extent if pl.presentationgrid.bbox_orignal_srid == 28992: (rec['bounds']['south'], rec['bounds']['west'], rec['bounds']['north'], rec['bounds']['east']) = extent rec['bounds']['projection'] = 28992 else: (rec['bounds']['west'], rec['bounds']['south'], rec['bounds']['east'], rec['bounds']['north']) = extent rec['bounds']['projection'] = 4326 rec['height'] = pl.presentationgrid.rownr rec['width'] = pl.presentationgrid.colnr rec['gridsize'] = pl.presentationgrid.gridsize anim = {} if (pl.presentationtype.value_type == PresentationType.VALUE_TYPE_TIME_SERIE): anim['firstnr'] = pl.animation.firstnr anim['lastnr'] = pl.animation.lastnr anim['options'] = {} anim['options']['startnr'] = pl.animation.startnr if (pl.animation.delta_timestep > 0): anim['options']['delta'] = pl.animation.delta_timestep * 24 * 3600 legends = pm.get_legends(pl) legend_objects = [{'id': l.id, 'name': l.name} for l in legends] default_legend = ShapeDataLegend.objects.get( pk=pl.presentationtype.default_legend_id) log.debug('got default legend') info = {} info['rec'] = rec info['anim'] = anim info['legends'] = legend_objects info['default_legend'] = { 'id': default_legend.id, 'name': default_legend.name } if ((pl.presentationtype.value_type == PresentationType.VALUE_TYPE_TIME_SERIE) and pl.presentationtype.geo_type in [ PresentationType.GEO_TYPE_POLYGON, PresentationType.GEO_TYPE_LINE, PresentationType.GEO_TYPE_POINT]): anim['lastnr'] = pl.animation.lastnr pass log.debug('json dump van info') log.debug(simplejson.dumps(info)) return HttpResponse(simplejson.dumps(info), mimetype="application/json")
def service_get_presentationlayer_settings(request, pl_id): """get_settings of presentationlayer return: overlaytype: presentationtype_overlaytype - integer - (wms, map, general, (point, line)) type: presentationtype_valuetype - integer - (timeserie, classification, singlevalue, static) has_value_source (kan ik waarden of grafieken van een punt opvragen??) legend: array of legends with: id: name: in case of default: dtype (0=personal default, 1=project default, 2=presentationType default) in case of grid: extent (in original srid) - north, south, west,east srid nrrows nrcols gridsize in case of animation: firstnr (nr first timestep) startnr (where default starts the animation slider) lastnr (nr last timestep) dt (delta time between timesteps) in case of classification: firstnr (nr first class) startnr (default class, which is first showed when ) lastnr (nr last timestep) array of class boundaries voor resultaten met figuren, haalt afmetingen en extents op """ pl = get_object_or_404(PresentationLayer, pk=pl_id) pm = PermissionManager(request.user) if not pm.check_permission( pl, PermissionManager.PERMISSION_PRESENTATIONLAYER_VIEW): raise Http404 result = pyramids.get_result_by_presentationlayer(pl) if result is not None and result.animation: return JSONResponse( pyramids.settings_for_animation(result.animation, result.scenario)) rec = {} if pl.presentationtype.geo_type == PresentationType.GEO_TYPE_GRID: try: pl.presentationgrid except PresentationGrid.DoesNotExist: return JSONResponse({}) rec['bounds'] = {} rec['bounds']['projection'] = pl.presentationgrid.bbox_orignal_srid extent = pl.presentationgrid.extent.extent if pl.presentationgrid.bbox_orignal_srid == 28992: (rec['bounds']['south'], rec['bounds']['west'], rec['bounds']['north'], rec['bounds']['east']) = extent rec['bounds']['projection'] = 28992 else: (rec['bounds']['west'], rec['bounds']['south'], rec['bounds']['east'], rec['bounds']['north']) = extent rec['bounds']['projection'] = 4326 rec['height'] = pl.presentationgrid.rownr rec['width'] = pl.presentationgrid.colnr rec['gridsize'] = pl.presentationgrid.gridsize anim = {} if (pl.presentationtype.value_type == PresentationType.VALUE_TYPE_TIME_SERIE): anim['firstnr'] = pl.animation.firstnr anim['lastnr'] = pl.animation.lastnr anim['options'] = {} anim['options']['startnr'] = pl.animation.startnr if (pl.animation.delta_timestep > 0): anim['options']['delta'] = pl.animation.delta_timestep * 24 * 3600 legends = pm.get_legends(pl) legend_objects = [{'id': l.id, 'name': l.name} for l in legends] default_legend = ShapeDataLegend.objects.get( pk=pl.presentationtype.default_legend_id) log.debug('got default legend') info = {} info['rec'] = rec info['anim'] = anim info['legends'] = legend_objects info['default_legend'] = { 'id': default_legend.id, 'name': default_legend.name } if ((pl.presentationtype.value_type == PresentationType.VALUE_TYPE_TIME_SERIE) and pl.presentationtype.geo_type in [ PresentationType.GEO_TYPE_POLYGON, PresentationType.GEO_TYPE_LINE, PresentationType.GEO_TYPE_POINT ]): anim['lastnr'] = pl.animation.lastnr pass log.debug('json dump van info') log.debug(json.dumps(info)) return JSONResponse(info)