mirror of
https://gitlab.crans.org/bde/nk20
synced 2024-11-26 18:37:12 +00:00
Update some excluded models
This commit is contained in:
parent
1c0bf21cbe
commit
10854eb334
@ -25,15 +25,17 @@ def get_user_in_signal(sender, **kwargs):
|
|||||||
return user
|
return user
|
||||||
|
|
||||||
EXCLUDED = [
|
EXCLUDED = [
|
||||||
'Changelog',
|
'changelog',
|
||||||
'Migration',
|
'migration',
|
||||||
'Session',
|
'revision',
|
||||||
|
'session',
|
||||||
|
'version',
|
||||||
]
|
]
|
||||||
|
|
||||||
@receiver(pre_save)
|
@receiver(pre_save)
|
||||||
def save_object(sender, instance, **kwargs):
|
def save_object(sender, instance, **kwargs):
|
||||||
model_name = sender.__name__
|
model_name = sender.__name__
|
||||||
if model_name in EXCLUDED:
|
if model_name.lower() in EXCLUDED:
|
||||||
return
|
return
|
||||||
|
|
||||||
previous = sender.objects.filter(pk=instance.pk).all()
|
previous = sender.objects.filter(pk=instance.pk).all()
|
||||||
@ -55,13 +57,13 @@ def save_object(sender, instance, **kwargs):
|
|||||||
@receiver(pre_delete)
|
@receiver(pre_delete)
|
||||||
def delete_object(sender, instance, **kwargs):
|
def delete_object(sender, instance, **kwargs):
|
||||||
model_name = sender.__name__
|
model_name = sender.__name__
|
||||||
if model_name in EXCLUDED:
|
if model_name.lower() in EXCLUDED:
|
||||||
return
|
return
|
||||||
|
|
||||||
user = get_user_in_signal(sender, **kwargs)
|
user = get_user_in_signal(sender, **kwargs)
|
||||||
instance_json = serializers.serialize('json', [instance, ])[1:-1]
|
instance_json = serializers.serialize('json', [instance, ])[1:-1]
|
||||||
Changelog.objects.create(user=user,
|
Changelog.objects.create(user=user,
|
||||||
model=model_name,
|
model=ContentType.objects.get_for_model(instance),
|
||||||
instance_pk=instance.pk,
|
instance_pk=instance.pk,
|
||||||
previous=instance_json,
|
previous=instance_json,
|
||||||
data=None,
|
data=None,
|
||||||
|
Loading…
Reference in New Issue
Block a user