Example #1
0
def get_events(request, address):
    request_data = request.POST
    if request.method == 'GET':
        request_data = request.GET
    params = {'cmd': 'EVENTS'}
    query = converter.create_query(request_data)
    obj_per_page = request_data.get('obj_per_page', "24")

    if query:
        archive_id = request_data.get('archive_id')
        if archive_id and len(archive_id) > 0:
            params['archive_id'] = archive_id.split(',')
        params['nPerPage'] = obj_per_page
        #add conditions
        filter = converter.query_for_archive(query)
        if filter:
            params['filter'] = filter
            print "---> filter:", params['filter']

    status, content_type, headers, cookies, data = utils.webapi_get_with_login(request.session, address, '/imr/config/api.jsp', params)

    data = xml_fix.fix(data)

    handler = events_handler.EventHandler()
    xml.sax.parseString(data, handler)
    
    return render_to_response('ssim/events/list.html', {
            'address':address,
            'events': handler.events,
            'fields': DEFAULT_FIELD_LIST,
            'obj_per_page': obj_per_page
        },
        mimetype="text/html")
Example #2
0
def get_event(request, address, guid):
    params = {'cmd': 'EVENTS', 'guid': guid}
    status, content_type, headers, cookies, data = utils.webapi_get_with_login(request.session, address, '/imr/config/api.jsp', params)

    data = xml_fix.fix(data)

    handler = events_handler.EventHandler()
    xml.sax.parseString(data, handler)

    return render_to_response('ssim/events/event.html', {
            'address':address,
            'event': handler.events[0],
            'fields': DEFAULT_FIELD_LIST,
        },
        mimetype="text/html")