From 19fcad448d6b0f748cb9585a41f748aea62ab1f3 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 17 Jul 2013 11:24:39 +0200 Subject: Fix cached forms that doesn't allow modeltypes update Don't instanciate the form passed to the widget --- ishtar_common/forms.py | 2 +- ishtar_common/widgets.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'ishtar_common') diff --git a/ishtar_common/forms.py b/ishtar_common/forms.py index 4477213c9..bc780ef9a 100644 --- a/ishtar_common/forms.py +++ b/ishtar_common/forms.py @@ -136,7 +136,7 @@ def get_form_selection(class_name, label, key, model, base_form, get_url, 'currents':{key:model},} attrs[key] = forms.IntegerField(label="", required=False, validators=[models.valid_id(model)], - widget=widgets.JQueryJqGrid(reverse_lazy(get_url), base_form(), model, + widget=widgets.JQueryJqGrid(reverse_lazy(get_url), base_form, model, new=new, new_message=new_message)) def clean(self): cleaned_data = self.cleaned_data diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py index af638aba7..d19b73b94 100644 --- a/ishtar_common/widgets.py +++ b/ishtar_common/widgets.py @@ -207,7 +207,8 @@ class JQueryJqGrid(forms.RadioSelect): def render(self, name, value=None, attrs=None): t = loader.get_template('blocks/form_snippet.html') - rendered = t.render(Context({'form':self.form})) + form = self.form() + rendered = t.render(Context({'form':form})) rendered += u"\n\n"\ u"" % ( name, unicode(_("Search"))) @@ -219,8 +220,8 @@ class JQueryJqGrid(forms.RadioSelect): rendered += "\n

%s

\n" % unicode(_("Search and select an item")) extra_cols = [] col_names, col_idx = [], [] - for k in self.form.get_input_ids(): - #field = self.form.fields[k] + for k in form.get_input_ids(): + #field = form.fields[k] col_idx.append(u'"%s"' % k) for field_name in getattr(self.associated_model, self.table_cols): field = self.associated_model -- cgit v1.2.3