From cfcbb04a4c2eb4cd587f34826f2ce69ff6025312 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 16 Nov 2018 17:55:00 +0100 Subject: Wizard: display selected on final wizard panel --- ishtar_common/forms.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'ishtar_common/forms.py') 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"" + )) + ] + + + class CustomFormSearch(forms.Form): need_user_for_initialization = True -- cgit v1.2.3