示例#1
0
def navigation_event_ids_by_user(user, start_date=None, end_date=None):
    database = NavigationEventAudit.get_db()

    def _date_key(date):
        return [date.year, date.month, date.day]

    startkey = [user]
    if start_date:
        startkey.extend(_date_key(start_date))

    endkey = [user]
    if end_date:
        end = end_date + timedelta(days=1)
        endkey.extend(_date_key(end))
    else:
        endkey.append({})

    ids = OrderedSet()
    results = database.view(
        'auditcare/urlpath_by_user_date',
        startkey=startkey,
        endkey=endkey,
        reduce=False,
        include_docs=False,
    )
    for row in results:
        ids.add(row['id'])
    return ids
示例#2
0
def navigation_event_ids_by_user(user):
    database = NavigationEventAudit.get_db()

    return {row['id'] for row in database.view('auditcare/urlpath_by_user_date',
        startkey=[user ],
        endkey=[user, {}],
        reduce=False,
        include_docs=False,
    )}
示例#3
0
 def rows(self):
     rows = []
     event_ids = navigation_event_ids_by_user(self.selected_user,
                                              self.datespan.startdate,
                                              self.datespan.enddate)
     for event_doc in iter_docs(NavigationEventAudit.get_db(), event_ids):
         event = NavigationEventAudit.wrap(event_doc)
         if not self.selected_domain or self.selected_domain == event.domain:
             rows.append([
                 event.event_date, event.user, event.domain or '',
                 event.ip_address, event.request_path
             ])
     return rows
def navigation_event_ids_by_user(user):
    database = NavigationEventAudit.get_db()

    return {
        row['id']
        for row in database.view(
            'auditcare/urlpath_by_user_date',
            startkey=[user],
            endkey=[user, {}],
            reduce=False,
            include_docs=False,
        )
    }
示例#5
0
def get_all_log_events(start_date=None, end_date=None):
    def _date_key(date):
        return [date.year, date.month, date.day]

    startkey = []
    if start_date:
        startkey.extend(_date_key(start_date))

    endkey = []
    if end_date:
        end = end_date + timedelta(days=1)
        endkey.extend(_date_key(end))
    else:
        endkey.append({})

    results = NavigationEventAudit.get_db().view(
        'auditcare/all_events',
        startkey=startkey,
        endkey=endkey,
        reduce=False,
        include_docs=True,
    )
    for row in results:
        yield wrap_audit_event(row['doc'])
 def tearDown(self):
     all_auditcare_ids = list(set([result["id"] for result in NavigationEventAudit.get_db().view(
         "auditcare/urlpath_by_user_date",
         reduce=False,
     ).all()]))
     iter_bulk_delete(NavigationEventAudit.get_db(), all_auditcare_ids)
示例#7
0
def write_log_events(writer, user, domain=None, override_user=None, start_date=None, end_date=None):
    event_ids = navigation_event_ids_by_user(user, start_date, end_date)
    for event in iter_docs(NavigationEventAudit.get_db(), event_ids):
        doc = NavigationEventAudit.wrap(event)
        if not domain or domain == doc.domain:
            write_log_event(writer, doc, override_user)
def log_events(writer, domain, user, override_user=""):
    for event in iter_docs(NavigationEventAudit.get_db(),
                           navigation_event_ids_by_user(user)):
        doc = NavigationEventAudit.wrap(event)
        if request_was_made_to_domain(domain, doc.request_path):
            log_event(writer, doc, override_user)
示例#9
0
def log_events(writer, domain, user, override_user=""):
    for event in iter_docs(NavigationEventAudit.get_db(), navigation_event_ids_by_user(user)):
        doc = NavigationEventAudit.wrap(event)
        if request_was_made_to_domain(domain, doc.request_path):
            log_event(writer, doc, override_user)