def test_update(self): p = ModelLog() event_id = randint(1, 100) user_id = randint(1, 100) p.save(event_id, user_id) p.save(event_id, user_id) self.__assert_logfile(event_id, "U", user_id, p.id)
def test_delete(self): p = ModelLog() event_id = randint(1, 100) user_id = randint(1, 100) p.save(event_id, user_id) instance_id = p.id p.delete(event_id, user_id) self.__assert_logfile(event_id, "D", user_id, instance_id)
def log_save(sender, **kwargs): if sender.__name__ == "ModelLog": return log = ModelLog() log.object_id = kwargs["instance"].id log.model_name = sender.__name__ if kwargs["created"]: log.action = "Create" else: log.action = "Edit" log.save()
def log_delete(sender, **kwargs): if sender.__name__ == "ModelLog": return log = ModelLog() log.object_id = kwargs["instance"].id log.model_name = sender.__name__ log.action = "Delete" log.save()