summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/models_common.py2
-rw-r--r--ishtar_common/templates/ishtar/sheet_ishtaruser.html2
-rw-r--r--ishtar_common/templatetags/ishtar_helpers.py10
-rw-r--r--ishtar_common/views_item.py7
4 files changed, 17 insertions, 4 deletions
diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py
index 4bea24ab5..49c69e9e1 100644
--- a/ishtar_common/models_common.py
+++ b/ishtar_common/models_common.py
@@ -881,7 +881,7 @@ class BaseSheetFilter(models.Model):
with open(tpl.template.origin.name, "r") as fle:
sub_content = fle.read()
keys += attrs.findall(sub_content)
- return sorted(set(keys))
+ return sorted(set([k.replace("_not_available", "") for k in keys]))
class SheetFilter(BaseSheetFilter):
diff --git a/ishtar_common/templates/ishtar/sheet_ishtaruser.html b/ishtar_common/templates/ishtar/sheet_ishtaruser.html
index e30df5278..ce351c720 100644
--- a/ishtar_common/templates/ishtar/sheet_ishtaruser.html
+++ b/ishtar_common/templates/ishtar/sheet_ishtaruser.html
@@ -69,7 +69,7 @@
<dt>{% trans "Profile(s)" %}</dt>
<dd>
{% for profile in item.person.profiles.all %}
- {% if forloop.counter0 %}; {% endif %}{{profile}} &nbsp;<a target="_blank" href="{{ profile.profile_type.admin_url }}{{profile.profile_type.id}}" title="Modifier">
+ {% if forloop.counter0 %}; {% endif %}{{profile.profile_type}} &nbsp;<a target="_blank" href="{{ profile.profile_type.admin_url }}{{profile.profile_type.id}}" title="Modifier">
<i class="fa fa-pencil"></i>
</a>
{% endfor %}
diff --git a/ishtar_common/templatetags/ishtar_helpers.py b/ishtar_common/templatetags/ishtar_helpers.py
index bfe7efc2a..cfd04a5d7 100644
--- a/ishtar_common/templatetags/ishtar_helpers.py
+++ b/ishtar_common/templatetags/ishtar_helpers.py
@@ -52,6 +52,14 @@ def and_(value1, value2):
@register.filter
+def safe_and_not(item, value):
+ try:
+ return item and not getattr(item, value, None) and item
+ except AttributeError:
+ return item
+
+
+@register.filter
def safe_or(item, args):
if not item:
return False
@@ -72,7 +80,7 @@ def safe_or(item, args):
if callable(current_item):
result = current_item()
if result:
- return True
+ return item
return False
diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py
index b30a9e525..cecc0318d 100644
--- a/ishtar_common/views_item.py
+++ b/ishtar_common/views_item.py
@@ -446,9 +446,14 @@ def filter_sheet(ishtar_user, item):
keys += base_keys
if exclude:
for key in keys:
+ param = getattr(item, key, None)
+ if hasattr(param, "count"):
+ # set a key_not_available variable in order to filter on the
+ # sheet non setable variable such as queryset or properties
+ setattr(item, key + "_not_available", True)
try:
setattr(item, key, None)
- except TypeError:
+ except (TypeError, AttributeError):
pass
return item
new_item = type("BaseObject", (object,), {})