Changeset fcfd2a in indico
- Timestamp:
- 08/10/11 14:06:04 (22 months ago)
- Branches:
- master, hello-world-walkthrough, ipv6, v0.98-series, v0.98.2, v0.98.3, v0.98b2, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, 0da0c1403bae8e51d8229f460181c71b9e6dda72
- Children:
- 15b835
- Parents:
- 90ed06
- git-author:
- Stefan Petrovski <stefan.petrovski@…> (06/10/11 16:58:02)
- git-committer:
- Pedro Ferreira <jose.pedro.ferreira@…> (08/10/11 14:06:04)
- Files:
-
- 4 edited
-
etc/indico.conf.sample (modified) (1 diff)
-
indico/MaKaC/common/Configuration.py (modified) (1 diff)
-
indico/MaKaC/webinterface/rh/conferenceBase.py (modified) (8 diffs)
-
indico/htdocs/js/indico/MaterialEditor/Editor.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
etc/indico.conf.sample
r8234edd rfcfd2a 150 150 # IndicoSearchClass = "MaKaC.search.invenioSEA.InvenioSEA" 151 151 152 #------------------------------------------------------------------------------ 153 # FILE UPLOAD 154 #------------------------------------------------------------------------------ 155 # Here you can limit the maximum size of uploaded files (in MB) 156 # default: 0 (unlimited) 157 158 MaxUploadFileSize = 0 152 159 153 160 #------------------------------------------------------------------------------ -
indico/MaKaC/common/Configuration.py
r8234edd rfcfd2a 466 466 'AuthenticatedEnforceSecure': 'yes', 467 467 'ExportACL' : {}, 468 468 'MaxUploadFileSize' : '1024', 469 469 # Authentication 470 470 'LDAPConfig': {'host': 'myldapserver.example.com', -
indico/MaKaC/webinterface/rh/conferenceBase.py
r0e7b55 rfcfd2a 39 39 from MaKaC.common.logger import Logger 40 40 41 from indico.util import json 42 43 BYTES_1MB = 1024 * 1024 44 45 41 46 class RHCustomizable( RH ): 42 47 … … 200 205 self._setMenuStatus(params) 201 206 207 202 208 class RHSubmitMaterialBase: 203 209 … … 211 217 self._target=target 212 218 self._callerRH = rh 219 self._req = rh._req 213 220 self._repositoryIds = None 221 self._errorList = [] 222 self._cfg = Config.getInstance() 214 223 215 224 def _getNewTempFile( self ): 216 225 cfg = Config.getInstance() 217 226 tempPath = cfg.getUploadedFilesTempDir() 218 tempFileName = tempfile.mkstemp( suffix="Indico.tmp", dir = tempPath)[1]227 tempFileName = tempfile.mkstemp(suffix="Indico.tmp", dir=tempPath)[1] 219 228 return tempFileName 220 229 … … 246 255 self._password = params.get("password","") 247 256 248 from MaKaC.services.interface.rpc import json249 self._userList = json.decode(params.get("userList", "[]"))257 self._userList = json.loads(params.get("userList", "[]")) 258 maxUploadFileSize = self._cfg.getMaxUploadFileSize() 250 259 251 260 if self._uploadType == "file": … … 260 269 if type(fileUpload) != str and fileUpload.filename.strip() != "": 261 270 fDict = {} 262 fDict["filePath"] = self._saveFileToTemp(fileUpload.file)263 264 if self._callerRH != None:265 self._callerRH._tempFilesToDelete.append(fDict["filePath"])266 271 267 272 fDict["fileName"] = fileUpload.filename 268 fDict["size"] = int(os.stat(fDict["filePath"])[stat.ST_SIZE]) 273 estimSize = int(self._req.headers_in["content-length"]) 274 275 if maxUploadFileSize and estimSize > (maxUploadFileSize * BYTES_1MB): 276 # if file is too big, do not save it in disk 277 fDict["filePath"] = '' 278 fDict["size"] = estimSize 279 else: 280 fDict["filePath"] = self._saveFileToTemp(fileUpload.file) 281 fDict["size"] = int(os.stat(fDict["filePath"])[stat.ST_SIZE]) 282 if self._callerRH != None: 283 self._callerRH._tempFilesToDelete.append(fDict["filePath"]) 284 285 self._setErrorList(fDict) 269 286 self._files.append(fDict) 270 287 … … 285 302 286 303 287 def _ getErrorList(self):304 def _setErrorList(self, fileEntry): 288 305 res=[] 289 306 307 maxUploadFileSize = self._cfg.getMaxUploadFileSize() 308 290 309 if self._uploadType == "file": 291 if not self._files:292 res.append(_("""A file must be submitted."""))293 for fileEntry in self._files:294 if hasattr(fileEntry, "filePath") and not fileEntry["filePath"].strip():295 res.append(_("""A valid file to be submitted must be specified."""))296 if hasattr(fileEntry, "size") and fileEntry["size"] < 10:297 res.append(_("""The file %s seems to be empty""") % fileEntry["fileName"])310 if "filePath" in fileEntry and not fileEntry["filePath"].strip(): 311 self._errorList.append(_("""A valid file to be submitted must be specified. """)) 312 if "size" in fileEntry: 313 if fileEntry["size"] < 10: 314 self._errorList.append(_("""The file %s seems to be empty """) % fileEntry["fileName"]) 315 elif maxUploadFileSize and fileEntry["size"] > (maxUploadFileSize*1024*1024): 316 self._errorList.append(_("The file size of %s exceeds the upload limit (%s Mb)") % (fileEntry["fileName"], maxUploadFileSize)) 298 317 elif self._uploadType == "link": 299 318 if not self._links[0]["url"].strip(): 300 res.append(_("""A valid URL must be specified."""))319 self._errorList.append(_("""A valid URL must be specified.""")) 301 320 302 321 if self._materialId=="": 303 res.append(_("""A material ID must be selected."""))322 self._errorList.append(_("""A material ID must be selected.""")) 304 323 return res 305 324 … … 454 473 text = "" 455 474 456 errorList=self._getErrorList()457 458 475 try: 459 if len( errorList) > 0:460 status = " ERROR"461 info = errorList476 if len(self._errorList) > 0: 477 status = "NOREPORT" 478 info = self._errorList 462 479 else: 463 480 mat, status, info = self._addMaterialType(text, user) … … 465 482 if status == "OK": 466 483 for entry in info: 467 entry['material'] = mat.getId() ;484 entry['material'] = mat.getId() 468 485 except Exception, e: 469 486 status = "ERROR" 470 info = errorList + ["%s: %s" % (e.__class__.__name__, str(e))]487 info = self._errorList + ["%s: %s" % (e.__class__.__name__, str(e))] 471 488 Logger.get('requestHandler').exception('Error uploading file') 472 473 489 # hackish, because of mime types. Konqueror, for instance, would assume text if there were no tags, 474 490 # and would try to open it 475 from MaKaC.services.interface.rpc import json 476 return "<html><head></head><body>"+json.encode({'status': status, 'info': info})+"</body></html>" 477 491 return "<html><head></head><body>%s</body></html>" %\ 492 json.dumps({'status': status, 'info': info}) -
indico/htdocs/js/indico/MaterialEditor/Editor.js
r8234edd rfcfd2a 67 67 return buttonDiv; 68 68 }, 69 70 69 71 70 /* … … 482 481 requestInfo: {}, 483 482 message: resp.info }); 483 } else if (resp.status == "NOREPORT") { 484 IndicoUtil.errorReport({ 485 type: "noReport", 486 code: '0', 487 requestInfo: {}, 488 message: resp.info }); 484 489 } else { 485 490 self.onUpload(resp.info);
Note: See TracChangeset
for help on using the changeset viewer.
