def test_get_auditlog_entries(self): modelname = 'blocked_reason' # Justification's db_table j1 = Justification.objects.create(name='j1') j2 = Justification.objects.create(name='j2') LogEntry.add_create_entry(self.justification, j1) LogEntry.add_log_entry( self.justification, u'greet', u'{actor} greets {object}', object=j2, subsystem="hello", ) LogEntry.add_log_entry( self.justification, u'deliver', u'{actor} delivers {object} to {target}', object=j1, target=j2, subsystem='delivery', ) entries = get_auditlog_entries(modelname=modelname) self.assertEqual(entries.count(), 3) entries = get_auditlog_entries(modelname=modelname, subsystem='hello') self.assertEqual(entries.count(), 1) entries = get_auditlog_entries(modelname=modelname, pks=[j1.pk]) self.assertEqual(entries.count(), 2)
def log_netbox_change(account, old, new): """Log specific user initiated changes to netboxes""" # If this is a new netbox if not old: LogEntry.add_create_entry(account, new) return # Compare changes from old to new attribute_list = [ 'read_only', 'read_write', 'category', 'ip', 'room', 'organization', 'snmp_version', ] LogEntry.compare_objects( account, old, new, attribute_list, censored_attributes=['read_only', 'read_write'], )
def log_account_change(actor, old, new): """Log change to account""" if not old: LogEntry.add_create_entry(actor, new) return attribute_list = ['login', 'name', 'password', 'ext_sync'] LogEntry.compare_objects(actor, old, new, attribute_list)
def test_add_create_entry(self): LogEntry.add_create_entry(self.justification, self.justification) l = LogEntry.objects.filter(verb=u'create-justification').get() self.assertEqual(l.summary, u'testarossa created testarossa') l.delete()
def post(self, request, *args, **kwargs): response = super(TokenCreate, self).post(request, *args, **kwargs) messages.success(request, 'New token created') LogEntry.add_create_entry(request.account, self.object) return response