Diff for /MPIWGWeb/MPIWGProjects.py between versions 1.47.2.21 and 1.47.2.22

version 1.47.2.21, 2005/08/31 08:24:29 version 1.47.2.22, 2005/09/14 20:45:56
Line 7  from Products.PageTemplates.PageTemplate Line 7  from Products.PageTemplates.PageTemplate
 from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate  from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
 from Products.ZSQLExtend.ZSQLExtend import ZSQLExtendFolder  from Products.ZSQLExtend.ZSQLExtend import ZSQLExtendFolder
 from Products.ZCatalog.CatalogPathAwareness import CatalogAware  from Products.ZCatalog.CatalogPathAwareness import CatalogAware
   from OFS.Image import Image
 from Globals import package_home  from Globals import package_home
 import urllib  import urllib
 import MPIWGStaff  import MPIWGStaff
Line 1137  def manage_addMPIWGRoot(self,id,title,co Line 1138  def manage_addMPIWGRoot(self,id,title,co
         RESPONSE.redirect('manage_main')          RESPONSE.redirect('manage_main')
                   
   
   class MPIWGProject_publication(SimpleItem):
       """publications object fuer project"""
   
       meta_type="MPIWGProject_publication"
   
       def editPublication(self,text=None,RESPONSE=None):
           """edit a publication"""
   
           if (not text):
               pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','edit_publicationForm.zpt')).__of__(self)
               return pt()
   
          
           self.text=text[0:]
   
           if RESPONSE:
               RESPONSE.redirect("../managePublications")
               
   class MPIWGProject_image(Image):
       """Images for Projects"""
   
       meta_type="MPIWGProject_image"
   
       def showImage(self,imageUrl=None):
           """show Images at an extra page"""
           self.getContent('WEB_project_description',filter='yes') #get the content and store image infos into session
           pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','projectImageView.zpt')).__of__(self)
           return pt()
       
       def editImage(self,file=None,caption=None,RESPONSE=None):
           """edit the Image"""
           if (not file) and (not caption):
               pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','edit_imageForm.zpt')).__of__(self)
               return pt()
   
           if file and (not file.filename.lstrip().rstrip()==""):
               self.manage_upload(file)
   
           if caption:
               self.caption=caption[0:]
   
           if RESPONSE:
               RESPONSE.redirect("../manageImages")
   
 class MPIWGProject(CatalogAware,Folder):  class MPIWGProject(CatalogAware,Folder):
     """Class for Projects"""      """Class for Projects"""
   
   
     security=ClassSecurityInfo()      security=ClassSecurityInfo()
     meta_type='MPIWGProject'      meta_type='MPIWGProject'
     default_catalog='ProjectCatalog'      default_catalog='ProjectCatalog'
           
       def sortedByPlace(self,metatype):
           """find metatype and sort by place"""
           def sort(x,y):
               return cmp(getattr(x[1],'place',0),getattr(y[1],'place',0))
   
           founds=self.ZopeFind(self,obj_metatypes=[metatype]);
           
           founds.sort(sort)
           
           return founds
       
   
       def copyPublicationsToList(self,RESPONSE=None):
           """copy publications in to list"""
   
           publicationTxt=self.getContent('WEB_related_pub')
   
           pubSplits=publicationTxt.split("<p>")
   
           for pubSplit in pubSplits:
               pubSplit=pubSplit.replace("</p>","")
               self.addPublication(pubSplit)
   
           if RESPONSE:
               RESPONSE.redirect('managePublications')
           
       
       def copyImageToMargin(self,RESPONSE=None):
           """copy inline images to marginal images"""
           self.getContent('WEB_project_description',filter='yes')
   
           filename=self.imageURL.split("/")[-1]
           #lege neues images object an, mit leerem bild
   
           if self.ZopeFind(self,obj_ids=[filename]):
               #existiert das bild schon, dann neueun filenamen
               filename="project_image_"+filename
               
           self.addImage(None,self.imagecap,filename=filename)
           #hole die bilddaten aus der url
           data=urllib.urlopen(self.absolute_url()+"/"+self.imageURL).read()
   
           obj=getattr(self,filename)
           obj.update_data(data)
           
           if RESPONSE:
               RESPONSE.redirect('manageImages')
               
       def manageImages(self,imageName=None,op=None):
           """managage images"""
   
   
           if imageName and op:
               if op=='up':
                   images=self.getImages()
                   for image in images:
                       if image[0]==imageName:
                           nr=images.index(image)
                           if not nr==0:
                               images[nr-1][1].place+=1
                               images[nr][1].place-=1
                           pass
               elif op=='down':
                   images=self.getImages()
                   for image in images:
                       if image[0]==imageName:
                           nr=images.index(image)
                           if not (nr==len(images)-1):
                               images[nr+1][1].place-=1
                               images[nr][1].place+=1
                           pass
   
   
           pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','MPIWGProject_manageImagesForm.zpt')).__of__(self)
           return pt()
   
       def managePublications(self,pubName=None,op=None):
           """managage images"""
   
   
           if pubName and op:
               if op=='up':
                   publications=self.getPublications()
                   for publication in publications:
                       if publication[0]==pubName:
                           nr=publications.index(publication)
                           if not nr==0:
                               publications[nr-1][1].place+=1
                               publications[nr][1].place-=1
                           pass
               elif op=='down':
                   publications=self.getPublications()
                   for publication in publications:
                       if publication[0]==pubName:
                           nr=publications.index(publication)
                           if not (nr==len(publications)-1):
                               publications[nr+1][1].place-=1
                               publications[nr][1].place+=1
                           pass
   
   
           pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','MPIWGProject_managePublicationsForm.zpt')).__of__(self)
           return pt()
   
       def getPublications(self):
           """get all Publications"""
           def sort_images(x,y):
               return cmp(getattr(x[1],'place',0),getattr(y[1],'place',0))
           print self.getId()
           publications=self.ZopeFind(self,obj_metatypes=['MPIWGProject_publication'])
           
           publications.sort(sort_images)
           return publications
   
       def addPublication(self,text,RESPONSE=None):
           """add an MPIWG_Publication"""
   
           name="publication_"+str(self.getLastPublicationNumber()+1)
           
           newPublication=MPIWGProject_publication(name)
   
           self._setObject(name,newPublication)
           obj=getattr(self,name)
           obj.text=text[0:]
           obj.enabled=True;
           obj.place=self.getLastPublicationNumber()+1
           obj.id=name
           
           if RESPONSE is not None:
               RESPONSE.redirect('managePublications')
   
    
       def getLastPublicationNumber(self):
           publications=self.getPublications()
           
           if not publications:
               return 0
           else:
               return getattr(publications[-1][1],'place',0)
           
       def deletePublication(self,id,RESPONSE=None):
           """delete Publication id"""
           self.manage_delObjects([id])
           if RESPONSE:
               RESPONSE.redirect('managePublications')
   
       def getImages(self):
           """get all Images"""
           def sort_images(x,y):
               return cmp(getattr(x[1],'place',0),getattr(y[1],'place',0))
           print self.getId()
           images=self.ZopeFind(self,obj_metatypes=['MPIWGProject_image'])
           
           images.sort(sort_images)
           return images
   
       def getLastImageNumber(self):
           images=self.getImages()
           
           if not images:
               return 0
           else:
               return getattr(images[-1][1],'place',0)
           
       def deleteImage(self,id,RESPONSE=None):
           """delete Image id"""
           self.manage_delObjects([id])
           if RESPONSE:
               RESPONSE.redirect('manageImages')
   
       def addImage(self,fileHd,caption,RESPONSE=None,filename=None):
           """add an MPIWG_Project_image"""
   
           if not filename:
               filename=fileHd.filename
   
           if not fileHd:
               fileHd=file(os.path.join(package_home(globals()),'blank.gif'))
               
           newImage=MPIWGProject_image(filename,filename,fileHd)
   
           self._setObject(filename,newImage)
           obj=getattr(self,filename)
           obj.caption=caption[0:]
           obj.enabled=True;
           obj.place=self.getLastImageNumber()+1
           
           if RESPONSE is not None:
               RESPONSE.redirect('manageImages')
   
     def PrincipiaSearchSource(self):      def PrincipiaSearchSource(self):
         """Return cataloguable key for ourselves."""          """Return cataloguable key for ourselves."""
         return str(self)          return str(self)
Line 1514  class MPIWGProject(CatalogAware,Folder): Line 1751  class MPIWGProject(CatalogAware,Folder):
         """get description"""          """get description"""
                   
         if type(self.WEB_project_description) is ListType:          if type(self.WEB_project_description) is ListType:
             return "<html><body>Hello"+self.WEB_project_description[0]+"</body></html>"              return "<html><body>"+self.WEB_project_description[0]+"</body></html>"
         else:          else:
             return self.WEB_project_description              return self.WEB_project_description
                   

Removed from v.1.47.2.21  
changed lines
  Added in v.1.47.2.22


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>