Centurion Audit Model
This model is the base model Audit model within Centurion ERP
Bases: CenturionModel
Centurion Audit History
This model is responsible for recording change to a model. The saving of
model history is via the delete
and save
signals
Attributes
action
action = IntegerField(
blank=False,
choices=Actions,
help_text="History action performed",
null=True,
validators=[validate_field_not_none],
verbose_name="Action",
)
after
after = JSONField(
blank=True,
help_text="Value Change to",
null=True,
validators=[validate_field_not_none],
verbose_name="After",
)
before
before = JSONField(
blank=True,
help_text="Value before Change",
null=True,
validators=[validate_field_not_none],
verbose_name="Before",
)
content_type
content_type = ForeignKey(
ContentType,
blank=True,
help_text="Model this history is for",
null=False,
on_delete=CASCADE,
validators=[validate_field_not_none],
verbose_name="Content Model",
)
table_fields
user
user = ForeignKey(
AUTH_USER_MODEL,
blank=False,
help_text="User whom performed the action",
null=False,
on_delete=PROTECT,
validators=[validate_field_not_none],
verbose_name="User",
)
Classes
Actions
Meta
Functions
get_model_history
Populate fields self.before
and self.after
Pass in the model that changed and this function will read values
model.before
and model.after
to populate the history table.
Note: Audit history expects all models to call and save to an
attribute before
self.__dict__
and after save to an attribute
called after
. Prior to calling the after, you must refresh from the
database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
Model
|
The model to get the history for |
required |
Returns:
Name | Type | Description |
---|---|---|
True |
bool
|
History fields populated |
Fail |
bool
|
History fields not populated |
About:
This page forms part of our Project Centurion ERP.
Page Metadata
Version: ToDo: place files short git commit hereDate Created: 2025-05-29
Date Edited: 2025-05-28
Contribution:
Would You like to contribute to our Centurion ERP project? You can assist in the following ways:
- Edit This Page If there is a mistake or a way you can improve it.
- Add a Page to the Manual if you would like to add an item to our manual
- Raise an Issue if there is something about this page you would like to improve, and git is unfamiliar to you.
ToDo: Add the page list of contributors