示例#1
0
文件: views.py 项目: saltybeagle/met
def search_service(request):
    filters = {}
    objects = []

    if 'entityid' in request.GET:
        form = ServiceSearchForm(request.GET)
        if form.is_valid():
            entityid = form.cleaned_data['entityid']
            entityid = entityid.strip()
            filters['entityid__icontains'] = entityid
    else:
        form = ServiceSearchForm()
    entity_type = request.GET.get('entity_type', None)

    if entity_type:
        filters['entity_type'] = entity_type

    if filters:
        objects = Entity.objects.filter(**filters)

    if objects and 'format' in request.GET.keys():
        entities = []
        for entity in objects:
            entities.append({
                'entityid':
                entity.entityid,
                'name':
                entity.name,
                'absolute_url':
                entity.get_absolute_url(),
                'types': [unicode(item) for item in entity.types.all()],
                'federations': [(unicode(item.name), item.get_absolute_url())
                                for item in entity.federations.all()],
            })

        return export_query_set(request.GET.get('format'), entities,
                                'entities_search_result',
                                ('entityid', 'types', 'federations'))

    entities = []
    for entity in objects:
        entities.append({
            'entityid':
            entity.entityid,
            'name':
            entity.name,
            'absolute_url':
            entity.get_absolute_url(),
            'types': [unicode(item) for item in entity.types.all()],
            'federations': [(unicode(item.name), item.get_absolute_url())
                            for item in entity.federations.all()],
        })

    return render_to_response('metadataparser/service_search.html', {
        'settings': settings,
        'searchform': form,
        'object_list': entities,
        'show_filters': False,
    },
                              context_instance=RequestContext(request))
示例#2
0
文件: views.py 项目: dpenezic/met
def search_service(request):
    filters = {}
    objects = []
    if request.method == 'GET':
        if 'entityid' in request.GET:
            form = ServiceSearchForm(request.GET)
            if form.is_valid():
                entityid = form.cleaned_data['entityid']
                entityid = entityid.strip()
                filters['entityid__icontains'] = entityid

        else:
            form = ServiceSearchForm()
        entity_type = request.GET.get('entity_type', None)
        if entity_type:
            filters['entity_type'] = entity_type
        if filters:
            objects = Entity.objects.filter(**filters)

    if objects and 'format' in request.GET.keys():
        return export_query_set(request.GET.get('format'), objects,
                                'entities_search_result', ('', 'types', 'federations'))

    return render_to_response('metadataparser/service_search.html',
        {'searchform': form,
         'object_list': objects,
         'show_filters': False,
        }, context_instance=RequestContext(request))
示例#3
0
文件: views.py 项目: GEANT/met
def search_service(request):
    filters = {}
    objects = []

    if 'entityid' in request.GET:
        form = ServiceSearchForm(request.GET)
        if form.is_valid():
            entityid = form.cleaned_data['entityid']
            entityid = entityid.strip()
            filters['entityid__icontains'] = entityid
    else:
        form = ServiceSearchForm()
    entity_type = request.GET.get('entity_type', None)

    if entity_type:
        filters['entity_type'] = entity_type

    if filters:
        objects = Entity.objects.filter(**filters)

    if objects and 'format' in request.GET.keys():
        entities = []
        for entity in objects:
            entities.append({
                'entityid': entity.entityid,
                'name': entity.name,
                'absolute_url': entity.get_absolute_url(),
                'types': [unicode(item) for item in entity.types.all()],
                'federations': [(unicode(item.name), item.get_absolute_url()) for item in entity.federations.all()],
            })

        return export_query_set(request.GET.get('format'), entities,
                                'entities_search_result', ('entityid', 'types', 'federations'))

    entities = []
    for entity in objects:
        entities.append({
            'entityid': entity.entityid,
            'name': entity.name,
            'absolute_url': entity.get_absolute_url(),
            'types': [unicode(item) for item in entity.types.all()],
            'federations': [(unicode(item.name), item.get_absolute_url()) for item in entity.federations.all()],
        })

    return render_to_response('metadataparser/service_search.html',
        {'settings': settings,
         'searchform': form,
         'object_list': entities,
         'show_filters': False,
        }, context_instance=RequestContext(request))