def inner(*args, **kwargs): resource_id = func(*args, **kwargs) Audit.add( Audit(g.user_id, Audit.Action.DELETE, resource_id, resource_type, resource_id)) return resource_id
def inner(*args, **kwargs): resource = func(*args, **kwargs) Audit.add( Audit(g.user_id, Audit.Action.CREATE, resource.id, resource_type, resource.current_version_id)) return resource
def get_audits_for_resource(self, resource_id, resource_type, limit=100, offset=0): audits = Audit.get_audit_for_resource_id(resource_id, resource_type, limit=limit+1, offset=offset) if not audits: return [] versions = AuditTarget.generate_versions_list(resource_id, resource_type, audits) for i in range(len(audits)-1): audit = audits[i] version = versions[i] last_version = versions[i + 1] audit.data = { "before": last_version.resource_content, "after": version.resource_content } audit.resource_visibility = { "before": Resource.Visibility.to_str(last_version.resource_visibility), "after": Resource.Visibility.to_str(version.resource_visibility) } audit.type = { "before": self.version_type_to_str(last_version.type), "after": self.version_type_to_str(version.type) } return audits[:-1]
def inner(*args, **kwargs): resource_id = kwargs.get("resource_id", None) assert resource_id is not None, "modify function must have resource_id keyword argument" resource_model = get_resource_model(resource_type) origin_resource = resource_model.get_by_id(resource_id) record_version(origin_resource, resource_type) result = func(*args, **kwargs) new_resource = resource_model.get_by_id(resource_id) Audit.add( Audit(g.user_id, Audit.Action.MODIFY, resource_id, resource_type, new_resource.current_version_id)) return result
def get_audit_count(self): return Audit.get_audit_count_for_resource_id(self.resource.id)
def get_audit_count(self): return Audit.get_audit_count_for_resource(self.resource.id, Resource.Type.ITEM)