changeset 21:d801453fd85f

getProjectsAndTagsAsCSV
author dwinter
date Wed, 29 Feb 2012 14:47:02 +0100
parents 82e72e034b0b
children d97e5e989c43
files MPIWGThesaurus.py
diffstat 1 files changed, 57 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/MPIWGThesaurus.py	Wed Feb 29 09:29:17 2012 +0100
+++ b/MPIWGThesaurus.py	Wed Feb 29 14:47:02 2012 +0100
@@ -233,6 +233,24 @@
             redirect(RESPONSE,'manage_main')
     
     
+    def getProjectsAndTagsAsCSV(self,archived=1):
+        """alle projekte auch die nicht getaggten"""
+        retList=[]
+        for project in self.getProjectFields('WEB_title_or_short'):
+            proj = project[0]
+            p_name = project[1]
+            retProj=[]
+            if (not proj.isArchivedProject() and archived==1) or (proj.isArchivedProject() and archived==2):
+                retProj.append(self.utf8ify(p_name))  
+                retProj.append(self.utf8ify(proj.getContent('xdata_01')))   
+                retProj.append("|".join([person[1] for person in self.thesaurus.getPersonsFromProject(proj.getId())]))
+                retProj.append("|".join([person[1] for person in self.thesaurus.getHistoricalPlacesFromProject(proj.getId())]))
+                retProj.append("|".join([person[1] for person in self.thesaurus.getObjectsFromProject(proj.getId())]))
+                retProj.append("|".join(self.thesaurus.getTags(proj.getId())))
+                retList.append("\t".join(retProj))
+
+        return "\n".join(retList);
+    
     def getProjectsAndTags(self):
         """projekte und tags"""
        
@@ -244,7 +262,7 @@
                #              python:here.getProjectsWithTag('approaches',here.getTitle(level1))"><a tal:attributes="href
                #                                                         python:proj[0]"><span  tal:content="python:proj[1]">my proj</span><tal:x define="person python:proj[2]"><span
                #                                                                                                          class="person_projects" tal:content="person"/></tal:x></a></div>
-          #</div>
+               #</div>
             
             for subTag in self.tags.get(tag):
                 projs = self.getProjectsWithTag(tag,subTag)
@@ -707,6 +725,44 @@
         logging.debug(retList)
         return "["+",".join(retList)+"]"
     
+    
+    
+  
+    def getTags(self,projectID,RESPONSE=None):
+        """get all selected tagList"""
+        
+        
+        logging.debug("asking:"+projectID)
+        
+        
+        apps = self.getApproaches()+ self.getDisciplines();
+        retList=[]
+        for tagType in self.tags.keys():
+        
+            logging.debug("asking tag::"+repr(tagType))
+            
+            tags = getattr(self,"tags",None)
+            if tags is None:
+                continue;
+            
+            tagsStored=tags.get(tagType,None)
+            if tagsStored is None:
+                continue;
+            
+            for tag in tagsStored.keys(): #gehe durch alle gespeichteren approached
+                logging.debug("checking:"+tag)
+                currentTag = tagsStored.get(tag,None)
+                if currentTag is None:
+                    continue
+                if currentTag.has_key(projectID):
+                    retList.append(""" "%s" """%tag)
+        
+        if RESPONSE:
+            RESPONSE.setHeader('Content-Type', "application/json")
+        
+        logging.debug(retList)
+        return retList
+    
     def getDisciplines(self):
         
         self.disciplines=self.getEntriesFromTxt(self.disciplinesTxt)