Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have custom AuditLogModelRegistry #617

Closed
hoangquochung1110 opened this issue Mar 19, 2024 · 3 comments
Closed

Have custom AuditLogModelRegistry #617

hoangquochung1110 opened this issue Mar 19, 2024 · 3 comments

Comments

@hoangquochung1110
Copy link
Contributor

hoangquochung1110 commented Mar 19, 2024

I'd like to have sth like this

from auditlog.registry import AuditlogModelRegistry

create_only_auditlog = AuditlogModelRegistry(
    create=True,
    update=False,
    delete=False,
    access=False,
    custom={
        post_save=my_signal_handler
    }
)

create_only_auditlog.register(MyModel)

But the problem is that we can not use this create_only_auditlog

because model_instance_diff would throw KeyError as it always get the default auditlog

Can we have new settings attribute to declare our custom auditlogs ?

@hoangquochung1110 hoangquochung1110 changed the title Is there a way to have custom AuditLogModelRegistry Have custom AuditLogModelRegistry Mar 19, 2024
@hramezani
Copy link
Member

Thanks @hoangquochung1110 for this feature. having a new settings attributes seems a good idea

@hoangquochung1110
Copy link
Contributor Author

Hi @hramezani Can I open a PR for it ?

My plan is to have a new settings attr let's say AUDITLOG_REGISTRY

We also may have AuditlogRegistry which acts as "facilitator" which help keep track of auditlogs with a variety of different configurations.

And the last thing. we may modify model_instance_diff to get rid of its dependence on the default auditlog

@hramezani
Copy link
Member

@hoangquochung1110 Yes, go for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants