summaryrefslogtreecommitdiff
path: root/ishtar/ishtar_base/forms.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@peacefrogs.net>2011-07-02 01:31:53 +0200
committerÉtienne Loks <etienne.loks@peacefrogs.net>2011-07-02 01:31:53 +0200
commitca39f96f904b9332179819e68011cf10572faf80 (patch)
treea2a4783a03c120df41bd4f45b207511039ec8cde /ishtar/ishtar_base/forms.py
parente946d15e8532c40e9581b539691179e8b9dbfa9c (diff)
downloadIshtar-ca39f96f904b9332179819e68011cf10572faf80.tar.bz2
Ishtar-ca39f96f904b9332179819e68011cf10572faf80.zip
Packaging of archaelogical items (closes #500)
Diffstat (limited to 'ishtar/ishtar_base/forms.py')
-rw-r--r--ishtar/ishtar_base/forms.py24
1 files changed, 18 insertions, 6 deletions
diff --git a/ishtar/ishtar_base/forms.py b/ishtar/ishtar_base/forms.py
index 9faba2ac9..85c4371d4 100644
--- a/ishtar/ishtar_base/forms.py
+++ b/ishtar/ishtar_base/forms.py
@@ -191,6 +191,9 @@ class Wizard(NamedUrlSessionFormWizard):
continue
if hasattr(base_form, 'fields') and key in base_form.fields:
lbl = base_form.fields[key].label
+ if hasattr(base_form, 'associated_labels') \
+ and key in base_form.associated_labels:
+ lbl = base_form.associated_labels[key]
if not lbl:
continue
value = cleaned_data[key]
@@ -198,15 +201,24 @@ class Wizard(NamedUrlSessionFormWizard):
continue
if type(value) == bool:
if value == True:
- value = _("Yes")
+ value = _(u"Yes")
elif value == False:
- value = _("No")
+ value = _(u"No")
elif key in associated_models:
- item = associated_models[key].objects.get(pk=value)
- if hasattr(item, 'short_label'):
- value = item.short_label()
+ values = []
+ if "," in unicode(value):
+ values = unicode(value).split(",")
else:
- value = unicode(item)
+ values = [value]
+ rendered_values = []
+ for val in values:
+ item = associated_models[key].objects.get(pk=val)
+ if hasattr(item, 'short_label'):
+ value = item.short_label()
+ else:
+ value = unicode(item)
+ rendered_values.append(value)
+ value = u" ; ".join(rendered_values)
form_datas.append((lbl, value, ''))
if form_datas:
datas.append((form.form_label, form_datas))