Skip to content

Commit

Permalink
Convert AUDITLOG_EXCLUDE_TRACKING_MODELS to tuple before concatenate (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
aivarsk authored Dec 29, 2022
1 parent dff0dd0 commit 7f8edd5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion auditlog/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ def _get_exclude_models(
) -> List[ModelBase]:
exclude_models = [
model
for app_model in exclude_tracking_models + self.DEFAULT_EXCLUDE_MODELS
for app_model in tuple(exclude_tracking_models)
+ self.DEFAULT_EXCLUDE_MODELS
for model in self._get_model_classes(app_model)
]
return exclude_models
Expand Down
12 changes: 11 additions & 1 deletion auditlog_tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,17 @@ def test_register_from_settings_invalid_settings(self):
AUDITLOG_INCLUDE_ALL_MODELS=True,
AUDITLOG_EXCLUDE_TRACKING_MODELS=("auditlog_tests.SimpleExcludeModel",),
)
def test_register_from_settings_register_all_models_with_exclude_models(self):
def test_register_from_settings_register_all_models_with_exclude_models_tuple(self):
self.test_auditlog.register_from_settings()

self.assertFalse(self.test_auditlog.contains(SimpleExcludeModel))
self.assertTrue(self.test_auditlog.contains(ChoicesFieldModel))

@override_settings(
AUDITLOG_INCLUDE_ALL_MODELS=True,
AUDITLOG_EXCLUDE_TRACKING_MODELS=["auditlog_tests.SimpleExcludeModel"],
)
def test_register_from_settings_register_all_models_with_exclude_models_list(self):
self.test_auditlog.register_from_settings()

self.assertFalse(self.test_auditlog.contains(SimpleExcludeModel))
Expand Down

0 comments on commit 7f8edd5

Please sign in to comment.