comparison MPIWGProjects.py @ 97:7b96a85552aa

fix bugs in project editing. only show images with captions in project description.
author casties
date Tue, 21 May 2013 15:51:32 +0200
parents 2dd8e3be4a8e
children 84fa3f62ed85
comparison
equal deleted inserted replaced
96:2dd8e3be4a8e 97:7b96a85552aa
368 # {'label':'Edit ProjectInfo','action':'editMPIWGProjectForm'}, 368 # {'label':'Edit ProjectInfo','action':'editMPIWGProjectForm'},
369 # {'label':'Edit BasisInfo','action':'editMPIWGBasisForm'}, 369 # {'label':'Edit BasisInfo','action':'editMPIWGBasisForm'},
370 # {'label':'Edit Publications','action':'editMPIWGRelatedPublicationsForm'}, 370 # {'label':'Edit Publications','action':'editMPIWGRelatedPublicationsForm'},
371 # {'label':'Edit Themes & Disciplines','action':'editMPIWGDisciplinesThemesForm'}, 371 # {'label':'Edit Themes & Disciplines','action':'editMPIWGDisciplinesThemesForm'},
372 # {'label':'Versionmanager','action':'versionManageForm'}, 372 # {'label':'Versionmanager','action':'versionManageForm'},
373
374 # list of responsible scientists. entries are dicts with name, key, and username.
375 responsibleScientistsList = []
376
377 # thumbnail image
378 projectThumb = None
379 373
380 # 374 #
381 # templates 375 # templates
382 # 376 #
383 project_html = PageTemplateFile('zpt/project/project_index_html', globals()) 377 project_html = PageTemplateFile('zpt/project/project_index_html', globals())
419 self.creationTime = time.strftime("%Y%m%d%H%M%S", time.localtime())[0:] 413 self.creationTime = time.strftime("%Y%m%d%H%M%S", time.localtime())[0:]
420 self.id = id 414 self.id = id
421 self.title = id 415 self.title = id
422 self.isActiveFlag = True # Flag is true is the project is still active, False if accomplished 416 self.isActiveFlag = True # Flag is true is the project is still active, False if accomplished
423 self.responsibleScientistsList = [] # enthaelt die Lister der verantwortlichen Wissenschaftler in der Form (NAME, KEY), key ist "" flass Wissenschaftler nicht an unserem Haus 417 self.responsibleScientistsList = [] # enthaelt die Lister der verantwortlichen Wissenschaftler in der Form (NAME, KEY), key ist "" flass Wissenschaftler nicht an unserem Haus
418 self.projectThumb = None
424 419
425 if argv: 420 if argv:
426 for arg in definedFields: 421 for arg in definedFields:
427 try: 422 try:
428 setattr(self, arg, argv[arg]) 423 setattr(self, arg, argv[arg])
510 return t 505 return t
511 506
512 507
513 def getResponsibleScientistsList(self): 508 def getResponsibleScientistsList(self):
514 """returns a list with the responsible scientists as dicts with name, key, and shortname""" 509 """returns a list with the responsible scientists as dicts with name, key, and shortname"""
515 return self.responsibleScientistsList 510 return getattr(self, 'responsibleScientistsList', [])
516 511
517 512
518 def setResponsibleScientistsList(self, nameDict): 513 def setResponsibleScientistsList(self, nameDict):
519 """sets the responsibleScientistsList from nameDict. 514 """sets the responsibleScientistsList from nameDict.
520 List will be ordered like the responsible scientists field.""" 515 List will be ordered like the responsible scientists field."""
572 getUrl = MPIWGHelper.getUrl 567 getUrl = MPIWGHelper.getUrl
573 568
574 569
575 def getThumbUrl(self, default=None): 570 def getThumbUrl(self, default=None):
576 """returns the URL of the project thumbnail image""" 571 """returns the URL of the project thumbnail image"""
577 thumb = self.projectThumb 572 thumb = getattr(self, 'projectThumb', None)
578 if thumb is None: 573 if thumb is None:
579 # get thumb from list (thumb is last image) 574 # get thumb from list (thumb is last image)
580 imgs = self.getImageList() 575 imgs = self.getImageList()
581 if len(imgs) > 0: 576 if len(imgs) > 0:
582 thumb = imgs[-1] 577 thumb = imgs[-1]
1252 return self.REQUEST['URL1'] + "/" + self.getId() 1247 return self.REQUEST['URL1'] + "/" + self.getId()
1253 else: 1248 else:
1254 return self.REQUEST['URL1'] + "/no_project" 1249 return self.REQUEST['URL1'] + "/no_project"
1255 1250
1256 1251
1257 def saveFromPreview(self): 1252 def saveFromPreview(self, RESPONSE=None):
1258 """save content aus preview""" 1253 """save content aus preview"""
1259 self.WEB_project_description = self.previewTemplate.WEB_project_description[0:] 1254 self.WEB_project_description = self.previewTemplate.WEB_project_description[0:]
1260 self.REQUEST.RESPONSE.redirect("./index.html") 1255 #self.REQUEST.RESPONSE.redirect("./index.html")
1261 1256 if RESPONSE is not None:
1262 1257 return self.editDescription()
1263 def saveEditedContent(self, kupu=None, preview=None): 1258
1259
1260 def saveEditedContent(self, kupu=None, preview=None, RESPONSE=None):
1264 """save Edited content""" 1261 """save Edited content"""
1265 # logging.debug("saveEditedContent kupu=%s preview=%s"%(kupu,preview)) 1262 # logging.debug("saveEditedContent kupu=%s preview=%s"%(kupu,preview))
1266 1263
1267 if preview: 1264 if preview:
1268 kupu = preview 1265 kupu = preview
1266
1269 # find content of body tags 1267 # find content of body tags
1270 start = kupu.find("<body>") 1268 start = kupu.find("<body>")
1271 end = kupu.find("</body>") 1269 end = kupu.find("</body>")
1272 newcontent = kupu[start + 6:end] 1270 newcontent = kupu[start + 6:end]
1273 1271
1275 return self.preview(newcontent) 1273 return self.preview(newcontent)
1276 1274
1277 self.copyObjectToArchive() 1275 self.copyObjectToArchive()
1278 self.WEB_project_description = newcontent[0:] 1276 self.WEB_project_description = newcontent[0:]
1279 1277
1280 self.REQUEST.RESPONSE.redirect("./index.html") 1278 #self.REQUEST.RESPONSE.redirect("./index.html")
1281 1279
1282 return True 1280 if RESPONSE is not None:
1283 1281 return self.editDescription()
1282
1284 1283
1285 def getBreadcrumbs(self): 1284 def getBreadcrumbs(self):
1286 """return list of breadcrumbs from here to the root""" 1285 """return list of breadcrumbs from here to the root"""
1287 crumbs = [] 1286 crumbs = []
1288 # skip direct parent Folder /projects/ 1287 # skip direct parent Folder /projects/
1320 self._setObject("previewTemplate", tmpPro) 1319 self._setObject("previewTemplate", tmpPro)
1321 for field in definedFields: 1320 for field in definedFields:
1322 setattr(tmpPro, field, getattr(self, field)) 1321 setattr(tmpPro, field, getattr(self, field))
1323 tmpPro.WEB_project_description = description[0:] 1322 tmpPro.WEB_project_description = description[0:]
1324 tmpPro.invisible = True 1323 tmpPro.invisible = True
1325 pt = PageTemplateFile('zpt/previewFrame.zpt', globals()).__of__(self) 1324 pt = PageTemplateFile('zpt/project/edit_preview_frame', globals()).__of__(self)
1326 return pt() 1325 return pt()
1327 1326
1328 1327
1329 def isResponsibleScientist(self, key): 1328 def isResponsibleScientist(self, key):
1330 """teste ob eine Person in der Liste der respl. scientists auftaucht""" 1329 """teste ob eine Person in der Liste der respl. scientists auftaucht"""