Ignore:
Timestamp:
7 Jan 2015, 09:20:45 (10 years ago)
Author:
Henrik Bettermann
Message:

Modify redirect after adding documents.

Ensure that keys don't exist when adding documents.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/browser.py

    r12408 r12413  
    135135        document = createObject('waeup.%s' % doctype)
    136136        self.applyData(document, **data)
    137         self.context.addDocument(document)
     137        try:
     138            self.context.addDocument(document)
     139        except KeyError:
     140            self.flash(_('The id chosen already exists.'),
     141                       type='danger')
     142            return
    138143        doctype = getUtility(IDocumentsUtils).SELECTABLE_DOCTYPES_DICT[doctype]
    139144        self.flash(_('${a} added.', mapping = {'a': doctype}))
     
    141146        self.context.__parent__.logger.info(
    142147            '%s - added: %s %s' % (ob_class, doctype, document.document_id))
    143         self.redirect(self.url(self.context, u'manage'))
     148        self.redirect(self.url(self.context) +
     149            '/%s/manage' % document.document_id)
    144150        return
    145151
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/tests/test_browser.py

    r12408 r12413  
    117117
    118118        # Document can be edited
    119         self.browser.getLink("DOC1").click()
    120         self.browser.getLink("Manage").click()
    121119        self.browser.getControl(name="form.title").value = 'My first doc'
    122120        self.browser.getControl("Save").click()
     
    221219
    222220        # Document can be edited
    223         self.browser.getLink("DOC2").click()
    224         self.browser.getLink("Manage").click()
    225221        self.browser.getControl(name="form.title").value = 'My second doc'
    226222        self.browser.getControl(name="form.html_multilingual").value = """
     
    310306
    311307        # Document can be edited
    312         self.browser.getLink("DOC3").click()
    313         self.browser.getLink("Manage").click()
    314308        self.browser.getControl(name="form.rest_multilingual").value = """
    315309----------
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/browser.py

    r12397 r12413  
    9494    tabtwoactions = [_('Add product'), _('Remove selected'),_('Cancel')]
    9595
     96    @action(_('Add product'), style='primary', validator=NullValidator)
     97    def addSubunit(self, **data):
     98        self.redirect(self.url(self.context, 'addproduct'))
     99        return
     100
    96101    @jsaction(_('Remove selected'))
    97102    def delProducts(self, **data):
     
    106111    def cancel(self, **data):
    107112        self.redirect(self.url(self.context))
    108         return
    109 
    110     @action(_('Add product'), validator=NullValidator)
    111     def addSubunit(self, **data):
    112         self.redirect(self.url(self.context, 'addproduct'))
    113113        return
    114114
     
    131131            self.context.addProduct(product)
    132132        except KeyError:
    133             self.flash(_('The Id chosen already exists.'),
     133            self.flash(_('The id chosen already exists.'),
    134134                       type='danger')
    135135            return
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/browser_templates/containermanagepage.pt

    r12334 r12413  
    2020        </tbody>
    2121      </table>
     22      <br /><p i18n:translate="">Setting parameters no yet configured.</p>
    2223      <div tal:condition="view/availableActions">
    2324        <span tal:repeat="action view/actions" tal:omit-tag="">
Note: See TracChangeset for help on using the changeset viewer.