summaryrefslogtreecommitdiff
path: root/ishtar_common/forms.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/forms.py')
-rw-r--r--ishtar_common/forms.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/ishtar_common/forms.py b/ishtar_common/forms.py
index 20c65971e..63551ede2 100644
--- a/ishtar_common/forms.py
+++ b/ishtar_common/forms.py
@@ -341,6 +341,38 @@ class CustomForm(BSForm):
return sorted(customs, key=lambda x: x[1])
+class PkWizardSearch(object):
+ current_model = None
+ pk_key = None
+
+ @classmethod
+ def get_formated_datas(cls, cleaned_datas):
+ if not cls.current_model or not cls.pk_key:
+ return []
+ items = []
+ for data in cleaned_datas:
+ if not data or cls.pk_key not in data or not data[cls.pk_key]:
+ continue
+ pks = data[cls.pk_key]
+ for pk in unicode(pks).split(u','):
+ if not pk:
+ continue
+ try:
+ items.append(
+ unicode(cls.current_model.objects.get(pk=int(pk)))
+ )
+ except (cls.current_model.DoesNotExist, ValueError):
+ continue
+ return [
+ (u"",
+ mark_safe(
+ u"<ul class='compact'><li>" + u"</li><li>".join(items) +
+ u"</li></ul>"
+ ))
+ ]
+
+
+
class CustomFormSearch(forms.Form):
need_user_for_initialization = True