diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-02-08 15:04:13 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-02-08 15:04:13 +0100 |
commit | dffdc666dcbb8039d2a6fbd2c11b88de71fdfdbe (patch) | |
tree | 3c2344914281e04eb2c3b2baaac626551e0bae77 /ishtar_common/utils.py | |
parent | 6f990814acc6eb13656111e11b994bd892a82d7c (diff) | |
download | Ishtar-dffdc666dcbb8039d2a6fbd2c11b88de71fdfdbe.tar.bz2 Ishtar-dffdc666dcbb8039d2a6fbd2c11b88de71fdfdbe.zip |
Document duplicate - do not duplicate image - allow redirection to modify
Diffstat (limited to 'ishtar_common/utils.py')
-rw-r--r-- | ishtar_common/utils.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index e6283ae5e..e27b26e70 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -2029,6 +2029,7 @@ PRIVATE_FIELDS = ("id", "history_modifier", "order", "uuid") def duplicate_item(item, user=None, data=None): model = item.__class__ new = model.objects.get(pk=item.pk) + data = data or {} for field in model._meta.fields: # pk is in PRIVATE_FIELDS so: new.pk = None and a new @@ -2039,9 +2040,11 @@ def duplicate_item(item, user=None, data=None): setattr(new, field.name, None) if user: new.history_user = user - if data: - for k in data: - setattr(new, k, data[k]) + for k in data: + setattr(new, k, data[k]) + exclude_fields = getattr(model, "DUPLICATE_EXCLUDE", []) + for k in exclude_fields: + setattr(new, k, None) new.save() if hasattr(user, "user_ptr"): if hasattr(new, "history_creator"): |