Products.CMFPlone/plip-1486-redirection: Check whether file was provided to bulk upload
Stephan Klinger <jenkins-z4DKO/[email protected]>
| Newsgroups | gmane.comp.web.zope.plone.cvs |
|---|---|
| Message-ID | <[email protected]> |
Repository: Products.CMFPlone Branch: refs/heads/plip-1486-redirection Date: 2017-07-10T09:31:40+03:00 Author: Stephan Klinger (staeff) <[email protected]> Commit: https://github.com/plone/Products.CMFPlone/commit/c0266de068aa2eba1a21d8a6223640d428eca30e Check whether file was provided to bulk upload Files changed: M Products/CMFPlone/controlpanel/browser/redirects.py diff --git a/Products/CMFPlone/controlpanel/browser/redirects.py b/Products/CMFPlone/controlpanel/browser/redirects.py index bce124dbc..14a5c9918 100644 --- a/Products/CMFPlone/controlpanel/browser/redirects.py +++ b/Products/CMFPlone/controlpanel/browser/redirects.py @@ -252,6 +252,11 @@ def add(self, redirection, target, portal, storage, status): def upload(self, file, portal, storage, status): """Add the redirections from the CSV file `file`. If anything goes wrong, do nothing.""" + + # No file picked. Theres gotta be a better way to handle this. + if not file.filename: + status.addStatusMessage(_(u"Please pick a file to upload."), type='info') + return # Turn all kinds of newlines into LF ones. The csv module doesn't do # its own newline sniffing and requires either \n or \r. file = StringIO('\n'.join(file.read().splitlines())) ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot