How to use the geonode.maps.models.Map.objects.filter function in GeoNode

To help you get started, we’ve selected a few GeoNode examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GeoNode / geonode / geonode / base / templatetags / base_tags.py View on Github external
if vector_time_series:
            count_dict['vectorTimeSeries'] = vector_time_series[0]['count']

        facets = {
            'raster': count_dict.get('coverageStore', 0),
            'vector': count_dict.get('dataStore', 0),
            'vector_time': count_dict.get('vectorTimeSeries', 0),
            'remote': count_dict.get('remoteStore', 0),
            'wms': count_dict.get('wmsStore', 0),
        }

        # Break early if only_layers is set.
        if facet_type == 'layers':
            return facets

        maps = Map.objects.filter(title__icontains=title_filter)
        documents = Document.objects.filter(title__icontains=title_filter)

        if category_filter:
            maps = maps.filter(category__identifier__in=category_filter)
            documents = documents.filter(category__identifier__in=category_filter)
        if regions_filter:
            maps = maps.filter(regions__name__in=regions_filter)
            documents = documents.filter(regions__name__in=regions_filter)
        if owner_filter:
            maps = maps.filter(owner__username__in=owner_filter)
            documents = documents.filter(owner__username__in=owner_filter)
        if date_gte_filter:
            maps = maps.filter(date__gte=date_gte_filter)
            documents = documents.filter(date__gte=date_gte_filter)
        if date_lte_filter:
            maps = maps.filter(date__lte=date_lte_filter)
github GeoNode / geonode / geonode / search / normalizers.py View on Github external
def map_count(self):
        return Map.objects.filter(owner = self.o.user).count()
github GeoNode / geonode / geonode / maps / views.py View on Github external
def ajax_url_lookup(request):
    if request.method != 'POST':
        return HttpResponse(
            content='ajax user lookup requires HTTP POST',
            status=405,
            content_type='text/plain'
        )
    elif 'query' not in request.POST:
        return HttpResponse(
            content='use a field named "query" to specify a prefix to filter urls',
            content_type='text/plain')
    if request.POST['query'] != '':
        maps = Map.objects.filter(urlsuffix__startswith=request.POST['query'])
        if request.POST['mapid'] != '':
            maps = maps.exclude(id=request.POST['mapid'])
        json_dict = {
            'urls': [({'url': m.urlsuffix}) for m in maps],
            'count': maps.count(),
        }
    else:
        json_dict = {
            'urls': [],
            'count': 0,
        }
    return HttpResponse(
        content=json.dumps(json_dict),
        content_type='text/plain'
    )
github GeoNode / geonode / geonode / maps / utils.py View on Github external
def fix_baselayers(map_id):
    """
    Fix base layers for a given map.
    """

    try:
        id = int(map_id)
    except ValueError:
        logger.error('map_id must be an integer')
        return

    if not Map.objects.filter(pk=id).exists():
        logger.error('There is not a map with id %s' % id)
        return

    map = Map.objects.get(pk=id)
    # first we delete all of the base layers
    map.layer_set.filter(local=False).delete()

    # now we re-add them
    source = 0
    for base_layer in settings.MAP_BASELAYERS:
        if 'group' in base_layer:
            # layer_params
            layer_params = {}
            layer_params['selected'] = True
            if 'title' in base_layer:
                layer_params['title'] = base_layer['title']
github cartologic / cartoview / cartoview / workspace / views.py View on Github external
def workspace(request):
    owner = request.user
    apps = AppInstance.objects.filter(owner=owner)
    created_apps = AppInstance.objects.all()
    layers = Layer.objects.filter(owner=owner)
    maps = Map.objects.filter(owner=owner)
    maps_count = Map.objects.all().count()
    layers_count = Layer.objects.all().count()
    documents = Document.objects.filter(owner=owner)
    documents_count = Document.objects.all().count()
    groups = owner.group_list_all()
    groups_count = GroupProfile.objects.all().count()
    return render(
        request,
        template_name='workspace/workspace.html',
        context={
            'my_apps': apps,
            'my_layers': layers,
            'created_apps': created_apps,
            'my_maps': maps,
            'maps_count': maps_count,
            'layers_count': layers_count,
github GeoNode / geonode / geonode / contrib / worldmap / wm_extra / views.py View on Github external
def map_detail_wm(request, mapid, snapshot=None, template='wm_extra/maps/map_detail.html'):
    '''
    The view that show details of each map
    '''
    map_obj = _resolve_map(
        request,
        mapid,
        'base.view_resourcebase',
        _PERMISSION_MSG_VIEW)
    # Update count for popularity ranking,
    # but do not includes admins or resource owners
    if request.user != map_obj.owner and not request.user.is_superuser:
        Map.objects.filter(
            id=map_obj.id).update(
            popular_count=F('popular_count') + 1)

    if snapshot is None:
        config = map_obj.viewer_json(request)
    else:
        config = snapshot_config(snapshot, map_obj, request)

    config = json.dumps(config)
    layers = MapLayer.objects.filter(map=map_obj.id)
    links = map_obj.link_set.download()

    config = gxp2wm(config)

    context_dict = {
        'config': config,
github GeoNode / geonode / geonode / sitemap.py View on Github external
def items(self):
        permitted = get_objects_for_user(AnonymousUser(), 'base.view_resourcebase')
        return Map.objects.filter(id__in=permitted)