Mercurial > hg > MPIWGThesaurus
comparison MPIWGThesaurus.py @ 21:d801453fd85f
getProjectsAndTagsAsCSV
author | dwinter |
---|---|
date | Wed, 29 Feb 2012 14:47:02 +0100 |
parents | 82e72e034b0b |
children | d97e5e989c43 |
comparison
equal
deleted
inserted
replaced
20:82e72e034b0b | 21:d801453fd85f |
---|---|
231 | 231 |
232 if RESPONSE is not None: | 232 if RESPONSE is not None: |
233 redirect(RESPONSE,'manage_main') | 233 redirect(RESPONSE,'manage_main') |
234 | 234 |
235 | 235 |
236 def getProjectsAndTagsAsCSV(self,archived=1): | |
237 """alle projekte auch die nicht getaggten""" | |
238 retList=[] | |
239 for project in self.getProjectFields('WEB_title_or_short'): | |
240 proj = project[0] | |
241 p_name = project[1] | |
242 retProj=[] | |
243 if (not proj.isArchivedProject() and archived==1) or (proj.isArchivedProject() and archived==2): | |
244 retProj.append(self.utf8ify(p_name)) | |
245 retProj.append(self.utf8ify(proj.getContent('xdata_01'))) | |
246 retProj.append("|".join([person[1] for person in self.thesaurus.getPersonsFromProject(proj.getId())])) | |
247 retProj.append("|".join([person[1] for person in self.thesaurus.getHistoricalPlacesFromProject(proj.getId())])) | |
248 retProj.append("|".join([person[1] for person in self.thesaurus.getObjectsFromProject(proj.getId())])) | |
249 retProj.append("|".join(self.thesaurus.getTags(proj.getId()))) | |
250 retList.append("\t".join(retProj)) | |
251 | |
252 return "\n".join(retList); | |
253 | |
236 def getProjectsAndTags(self): | 254 def getProjectsAndTags(self): |
237 """projekte und tags""" | 255 """projekte und tags""" |
238 | 256 |
239 | 257 |
240 projectTags={} | 258 projectTags={} |
242 logging.debug("getProjectsAndTags:"+tag) | 260 logging.debug("getProjectsAndTags:"+tag) |
243 # <div class="level1_projects" tal:repeat="proj | 261 # <div class="level1_projects" tal:repeat="proj |
244 # python:here.getProjectsWithTag('approaches',here.getTitle(level1))"><a tal:attributes="href | 262 # python:here.getProjectsWithTag('approaches',here.getTitle(level1))"><a tal:attributes="href |
245 # python:proj[0]"><span tal:content="python:proj[1]">my proj</span><tal:x define="person python:proj[2]"><span | 263 # python:proj[0]"><span tal:content="python:proj[1]">my proj</span><tal:x define="person python:proj[2]"><span |
246 # class="person_projects" tal:content="person"/></tal:x></a></div> | 264 # class="person_projects" tal:content="person"/></tal:x></a></div> |
247 #</div> | 265 #</div> |
248 | 266 |
249 for subTag in self.tags.get(tag): | 267 for subTag in self.tags.get(tag): |
250 projs = self.getProjectsWithTag(tag,subTag) | 268 projs = self.getProjectsWithTag(tag,subTag) |
251 if not isinstance(projs, ListType): | 269 if not isinstance(projs, ListType): |
252 projs=[projs] | 270 projs=[projs] |
705 RESPONSE.setHeader('Content-Type', "application/json") | 723 RESPONSE.setHeader('Content-Type', "application/json") |
706 | 724 |
707 logging.debug(retList) | 725 logging.debug(retList) |
708 return "["+",".join(retList)+"]" | 726 return "["+",".join(retList)+"]" |
709 | 727 |
728 | |
729 | |
730 | |
731 def getTags(self,projectID,RESPONSE=None): | |
732 """get all selected tagList""" | |
733 | |
734 | |
735 logging.debug("asking:"+projectID) | |
736 | |
737 | |
738 apps = self.getApproaches()+ self.getDisciplines(); | |
739 retList=[] | |
740 for tagType in self.tags.keys(): | |
741 | |
742 logging.debug("asking tag::"+repr(tagType)) | |
743 | |
744 tags = getattr(self,"tags",None) | |
745 if tags is None: | |
746 continue; | |
747 | |
748 tagsStored=tags.get(tagType,None) | |
749 if tagsStored is None: | |
750 continue; | |
751 | |
752 for tag in tagsStored.keys(): #gehe durch alle gespeichteren approached | |
753 logging.debug("checking:"+tag) | |
754 currentTag = tagsStored.get(tag,None) | |
755 if currentTag is None: | |
756 continue | |
757 if currentTag.has_key(projectID): | |
758 retList.append(""" "%s" """%tag) | |
759 | |
760 if RESPONSE: | |
761 RESPONSE.setHeader('Content-Type', "application/json") | |
762 | |
763 logging.debug(retList) | |
764 return retList | |
765 | |
710 def getDisciplines(self): | 766 def getDisciplines(self): |
711 | 767 |
712 self.disciplines=self.getEntriesFromTxt(self.disciplinesTxt) | 768 self.disciplines=self.getEntriesFromTxt(self.disciplinesTxt) |
713 return self.disciplines | 769 return self.disciplines |
714 | 770 |