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.

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.