summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2017-07-11 14:49:28 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2017-07-11 14:49:28 +0200
commit4fcc46584a2f55048173c0d718be5bf76a74127d (patch)
tree2054df617244c89d93b7a3b678d13ea25d78a92f /ishtar_common
parentf64baa1026aaf79e62cd604ac94dc21382f07e5a (diff)
parentfba85439ce71086c6153cb3bb57b48567bbfad85 (diff)
downloadIshtar-4fcc46584a2f55048173c0d718be5bf76a74127d.tar.bz2
Ishtar-4fcc46584a2f55048173c0d718be5bf76a74127d.zip
Merge branch 'master' into v0.9
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/forms_common.py2
-rw-r--r--ishtar_common/tests.py30
-rw-r--r--ishtar_common/wizards.py9
3 files changed, 36 insertions, 5 deletions
diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py
index 61e9f1a88..44af3a588 100644
--- a/ishtar_common/forms_common.py
+++ b/ishtar_common/forms_common.py
@@ -595,7 +595,7 @@ class AccountForm(forms.Form):
if 'person' in kwargs:
person = kwargs.pop('person')
super(AccountForm, self).__init__(*args, **kwargs)
- if person:
+ if person and person.raw_name:
self.fields['username'].initial = \
person.raw_name.lower().replace(' ', '.')
diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py
index 174918dd4..536d6d4a8 100644
--- a/ishtar_common/tests.py
+++ b/ishtar_common/tests.py
@@ -129,15 +129,45 @@ class WizardTestFormData(object):
accepting two parameters: the current test object and the final step
response
"""
+ self.name = name
self.form_datas = form_datas
self.ignored = ignored[:]
self.pre_tests = pre_tests
self.extra_tests = extra_tests
+ def set(self, form_name, field_name, value):
+ """
+ Set data value.
+
+ :param form_name: form name without wizard name
+ :param field_name: field name
+ :param value: value
+ :return: None
+ """
+ self.form_datas[form_name][field_name] = value
+
+ def append(self, form_name, value):
+ """
+ Add data value to formset.
+
+ :param form_name: form name without wizard name
+ :param value: value
+ :return: None
+ """
+ self.form_datas[form_name].append(value)
+
def inits(self, test_object):
"""
Initialisations before the wizard.
"""
+
+ suffix = '-' + test_object.url_name
+ # if form names are defined without url_name fix it
+ for form_name in self.form_datas.keys():
+ if suffix in form_name:
+ continue
+ self.form_datas[form_name + suffix] = self.form_datas.pop(form_name)
+
for pre in self.pre_tests:
pre(test_object)
diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py
index 8d787d733..3f90f8c48 100644
--- a/ishtar_common/wizards.py
+++ b/ishtar_common/wizards.py
@@ -1232,10 +1232,11 @@ class DeletionWizard(Wizard):
def done(self, form_list, **kwargs):
obj = self.get_current_object()
- try:
- obj.delete()
- except ObjectDoesNotExist:
- pass
+ if obj:
+ try:
+ obj.delete()
+ except ObjectDoesNotExist:
+ pass
return render_to_response(
'ishtar/wizard/wizard_delete_done.html', {},
context_instance=RequestContext(self.request))