Commit ee5c1798 authored by Thibaut Deheunynck's avatar Thibaut Deheunynck

Now you can insert a RadioField in ERP5Form render only ( not in graphic...

Now you can insert a RadioField in ERP5Form render only ( not in graphic render ) when you create a new module with scribus. Add a test to check it

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@21717 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a197b5cc
......@@ -1788,8 +1788,8 @@ class ScribusParser:
# from scribus type (selected in the scribus PDF-form properties)
object_type = str(object_content['ANTYPE'])
if object_type == '2':
#type 2 = PDF-Button
object_properties['type'] = 'Button'
#type 2 = PDF-Button : InputButtonField
object_properties['type'] = 'InputButtonField'
elif object_type == '3':
#type 3 = PDF-Text : Stringfield by default
object_properties['type'] = 'StringField'
......@@ -1879,8 +1879,8 @@ class ScribusParser:
# object is listbox, and listbox have several possible values
# WARNING listbox have not been tested in graphic rendering for
# the moment. is there any use for listbox in PDF-like rendering ?
if str(object_properties['type']) == 'ListBox' :
# checking if this listbox has different possible values
if str(object_properties['type']) in ('ListBox', 'RadioField') :
# checking if this listbox and the radioField has different possible values
object_properties['items'] = \
sp.getObjectTooltipProperty('items',
'',
......@@ -2141,13 +2141,13 @@ class ScribusParser:
properties_field['catalog_index']
object_dict['attributes']['default_module'] =\
properties_field['default_module']
# idem : special field concerning RadioField (not tested)
# idem : special field concerning RadioField ( tested )
elif object_dict['erp_type'] == 'RadioField':
# radio fields have not been tested for the moment
items = []
for word_item in properties_field['item'].split('|'):
for word_item in properties_field['items'].split('|'):
items.append((word_item, word_item.capitalize()))
object_dict['attributes'] = items
object_dict['attributes']['items'] = items
#elif object_dict['erp_type'] == 'CheckBoxField':
# checkboxfield needs to have their field data updated
# this is not done automatically so it is needed to do
......
This diff is collapsed.
......@@ -380,6 +380,37 @@ class TestScribusUtils(ERP5TypeTestCase):
form = self.portal.portal_skins.erp5_empty.Empty_view
self.assertEquals(0, len(form.objectValues()))
def test_09_creationRadioField(self):
'''check it's possible to put a field radioField in ERP5 Form created with
scribus.
Create a RadioField if possible only when you use ERP5 Form rendering
and not graphic rendering
RadioField with 3 items : young, adult and senior
'''
self.portal.ERP5Site_createModuleScribus(
module_portal_type="Radio Module",
portal_skins_folder="erp5_radio",
object_portal_type="Radio",
object_title="Radio",
module_id="radio_module",
module_title="Radio Module Title",
import_pdf_file=self.makeFileUpload('test_RadioField.pdf'),
import_scribus_file=self.makeFileUpload('test_RadioField.sla'),)
self.assertNotEqual(self.portal._getOb('radio_module', None), None)
self.assertNotEqual(
self.portal.portal_skins._getOb("erp5_radio", None), None)
self.assertEquals("Radio Module Title",
self.portal.radio_module.getTitle())
self.assertNotEqual(self.portal.portal_types.getTypeInfo("Radio Module"),
None)
self.assertNotEqual(self.portal.portal_types.getTypeInfo("Radio"), None)
form = self.portal.portal_skins.erp5_radio.Radio_view
field_radio = form.my_radio
self.assertEquals(3,
len(field_radio.get_value('items')))
items_list = [('young', 'Young'), ('adult', 'Adult'), ('senior', 'Senior')]
self.assertEquals(items_list, field_radio.get_value('items'))
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestScribusUtils))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment