flexmeasures.data.models.audit_log

Functions

flexmeasures.data.models.audit_log.get_current_user_id_name()
flexmeasures.data.models.audit_log.truncate_string(value: str, max_length: int) str

Truncate a string and add ellipses in the middle if it exceeds max_length.

Classes

class flexmeasures.data.models.audit_log.AssetAuditLog(**kwargs)

Model for storing actions that happen to an asset. E.g asset creation, editing etc.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

classmethod add_record(asset: GenericAsset | Sensor, event: str) None

Add audit log record about asset related crud actions.

Parameters:
  • asset – asset or sensor object

  • event – event to log

classmethod add_record_for_attribute_update(attribute_key: str, attribute_value: float | int | bool | str | list | dict | None, entity_type: str, asset_or_sensor: GenericAsset | Sensor) None

Add audit log record about asset or sensor attribute update.

Parameters:
  • attribute_key – attribute key to update

  • attribute_value – new attribute value

  • entity_type – ‘asset’ or ‘sensor’

  • asset_or_sensor – asset or sensor object

class flexmeasures.data.models.audit_log.AuditLog(**kwargs)

Model for storing actions that happen to user and tenant accounts E.g user creation, password reset etc.

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

classmethod account_table_acl(account: Account)

Table-level access rules for account-affecting audit logs. Use directly in check_access or in @permission_required_for_context with pass_ctx_to_loader, ctx_loader=AuditLog.user_acl. Permissions:

Account-admin users can see audit logs for their account. Admins / admin-readers can see audit logs for all accounts. Consultant users can see the audit log of all client accounts.

classmethod user_table_acl(user: User)

Table-level access rules for user-affecting audit logs. Use directly in check_access or in @permission_required_for_context with pass_ctx_to_loader, ctx_loader=AuditLog.user_acl. Permissions:

User can see his own audit logs. Account-admin users can see audit logs for all users of their account. Admins / admin-readers can see audit logs for all users. Consultant users can see the audit log of all users in the client accounts.