def create_features(variant, graph, do_create_edges=True): """Create features (points/lines) and popups from a graph.""" variant_config = get_configuration()['variants'][variant] indicators = variant_config['indicators'] styles = variant_config['styles'] template_files = variant_config['template_files'] node_popup_template = load_popup_template(template_files['node_popup']) node_feature_creator = partial( create_node_feature, popup_template=node_popup_template, default_style=styles['node'], indicators=indicators['node'], ) nodes = [node_feature_creator(n) for n in graph.nodes.values()] edges = [] if do_create_edges: edge_popup_template = load_popup_template(template_files['edge_popup']) edge_feature_creator = partial( create_edge_features, popup_template=edge_popup_template, default_style=styles['edge'], indicators=indicators['edge'], ) edges = concat_list([edge_feature_creator(e) for e in graph.edges.values()]) return nodes + edges
def forward_to_default_variant(request): """Redirect the client to the default variant. The default variant is the one listed first in the configuration file. """ account = get_account(request) for variant in get_configuration()['variant_order']: url = reverse('geomap', args=(variant, )) if account.has_perm('web_access', url): return HttpResponseRedirect(url) return HttpResponseForbidden # TODO: should use 'Unauthorized'
def forward_to_default_variant(request): """Redirect the client to the default variant. The default variant is the one listed first in the configuration file. """ account = get_account(request) for variant in get_configuration()['variant_order']: url = reverse('geomap', args=(variant,)) if account.has_perm('web_access', url): return HttpResponseRedirect(url) return HttpResponseForbidden # TODO: should use 'Unauthorized'
def create_features(variant, graph): """Create features (points/lines) and popups from a graph.""" variant_config = get_configuration()['variants'][variant] indicators = variant_config['indicators'] styles = variant_config['styles'] template_files = variant_config['template_files'] node_popup_template = load_popup_template(template_files['node_popup']) edge_popup_template = load_popup_template(template_files['edge_popup']) node_feature_creator = fix( create_node_feature, [node_popup_template, styles['node'], indicators['node']], 1) edge_feature_creator = fix( create_edge_features, [edge_popup_template, styles['edge'], indicators['edge']], 1) nodes = map(node_feature_creator, graph.nodes.values()) edges = concat_list(map(edge_feature_creator, graph.edges.values())) return nodes + edges
def create_features(variant, graph): """Create features (points/lines) and popups from a graph.""" variant_config = get_configuration()['variants'][variant] indicators = variant_config['indicators'] styles = variant_config['styles'] template_files = variant_config['template_files'] node_popup_template = load_popup_template(template_files['node_popup']) edge_popup_template = load_popup_template(template_files['edge_popup']) node_feature_creator = fix(create_node_feature, [node_popup_template, styles['node'], indicators['node']], 1) edge_feature_creator = fix(create_edge_features, [edge_popup_template, styles['edge'], indicators['edge']], 1) nodes = map(node_feature_creator, graph.nodes.values()) edges = concat_list(map(edge_feature_creator, graph.edges.values())) return nodes+edges
def geomap(request, variant): """Create the page showing the map. variant must be a variant name defined in the configuration file. """ config = get_configuration() if variant not in config['variants']: raise Http404 room_points = geomap_all_room_pos() _logger.debug('geomap: room_points = %s', room_points) variant_config = config['variants'][variant] context = { 'title': 'NAV - Geomap', 'navpath': [('Home', '/'), ('Geomap', None)], 'room_points': room_points, 'config': config, 'variant': variant, 'variant_config': variant_config, } return render(request, 'geomap/geomap.html', context)
def geomap(request, variant): """Create the page showing the map. variant must be a variant name defined in the configuration file. """ config = get_configuration() if variant not in config['variants']: raise Http404 room_points = geomap_all_room_pos() logger.debug('geomap: room_points = %s' % room_points) variant_config = config['variants'][variant] context = { 'title': 'NAV - Geomap', 'navpath': [('Home', '/'), ('Geomap', None)], 'room_points': room_points, 'config': config, 'variant': variant, 'variant_config': variant_config, } return render_to_response('geomap/geomap.html', context, RequestContext(request))