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 | 61518a66e417c2c210291d0b589dae8e02a8083f (patch) | |
tree | 3c2344914281e04eb2c3b2baaac626551e0bae77 /ishtar_common/utils.py | |
parent | f4f80f3b5f716fea97cfa58612ef1d04ada378c1 (diff) | |
download | Ishtar-61518a66e417c2c210291d0b589dae8e02a8083f.tar.bz2 Ishtar-61518a66e417c2c210291d0b589dae8e02a8083f.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"): |