summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2021-09-16 14:27:34 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2022-12-12 12:20:58 +0100
commit4970a276e34a9fd14cae13281242b23755d5f5e9 (patch)
tree082caee7a417b55f352fc225a3aedc1cee3a6cd0
parentec2fc0e18a490634a2da97a16ac94725c3acdc32 (diff)
downloadIshtar-4970a276e34a9fd14cae13281242b23755d5f5e9.tar.bz2
Ishtar-4970a276e34a9fd14cae13281242b23755d5f5e9.zip
Migration to Django 2.2 - fixes
- fix test - fix searches
-rw-r--r--ishtar_common/tests.py3
-rw-r--r--ishtar_common/views_item.py11
2 files changed, 8 insertions, 6 deletions
diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py
index 831eac25d..e3af9024f 100644
--- a/ishtar_common/tests.py
+++ b/ishtar_common/tests.py
@@ -544,6 +544,9 @@ class WizardTest(object):
if extra_data:
data.update(extra_data)
+ for k in data:
+ if data[k] is None:
+ data[k] = ""
try:
response = client.post(url, data, follow=follow)
except ValidationError as e:
diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py
index abe7fa11b..479a40419 100644
--- a/ishtar_common/views_item.py
+++ b/ishtar_common/views_item.py
@@ -791,7 +791,7 @@ def _manage_bool_fields(model, bool_fields, reversed_bool_fields, dct, or_reqs):
for k in bool_fields:
if k not in dct:
continue
- elif dct[k] == "1":
+ elif dct[k] == "1" or dct[k] == "unknown":
dct.pop(k)
continue
dct[k] = dct[k].replace('"', "")
@@ -828,7 +828,7 @@ def _manage_many_counted_fields(fields, reversed_fields, dct, excluded_dct):
for k in bool_fields:
if k not in dct:
continue
- elif dct[k] == "1":
+ elif dct[k] == "1" or dct[k] == "unknown":
dct.pop(k)
continue
dct[k] = dct[k].replace('"', "")
@@ -1031,12 +1031,10 @@ def _manage_hierarchic_fields(model, dct, and_reqs):
for k_hr in hierarchic_fields:
lbl_name = "label"
- try:
+ if hasattr(model, k_hr):
rel = getattr(model, k_hr).field.related_model
if not hasattr(rel, "label") and hasattr(rel, "cached_label"):
lbl_name = "cached_label"
- except:
- pass
if type(req) in (list, tuple):
val = dct.pop(req)
val = _clean_type_val(val)
@@ -1667,7 +1665,8 @@ def get_item(
[
(
field.name,
- field.name + (hasattr(field, "rel") and field.rel and "__pk" or ""),
+ field.name + (hasattr(field, "remote_field")
+ and field.remote_field and "__pk" or ""),
)
for field in fields
]