#-*- coding: utf-8 # Copyright 2005-2007 by Meelis Mets, Vahur Rebas from Products.Archetypes.public import BaseSchema, Schema from Products.Archetypes.public import StringField, LinesField from Products.Archetypes.public import LinesWidget, TextAreaWidget, IdWidget, StringWidget, SelectionWidget from Products.Archetypes.public import OrderedBaseFolder, registerType from Globals import InitializeClass from Products.CMFCore.utils import getToolByName from Common import CommonMix as Common from AccessControl import ClassSecurityInfo, Unauthorized from config import PROJECT_NAME schema = BaseSchema class Eportfolio(OrderedBaseFolder, Common): """ User's home folder """ meta_type = "Eportfolio" archetype_name = "Eportfolio" global_allow = 0 filter_content_types = True allowed_content_types = () security = ClassSecurityInfo() schema = schema actions = ( { 'id':'view', 'name':'View', 'action':'string:${object_url}/blog', 'permissions': ('View',), }, ) def manage_afterAdd(self,item,container): self.makePortfolioContent() #XXX Replaces the left side portlets with the content type's own action portlet OrderedBaseFolder.manage_afterAdd(self, item, container) if not hasattr(item.aq_base, 'left_slots'): self._setProperty('left_slots', ['here/portlet_eportfolio/macros/portlet',], 'lines') if not hasattr(item.aq_base, 'right_slots'): self._setProperty('right_slots', ['here/portlet_calendar/macros/portlet',], 'lines') def getLargeIcon(self): """ returns subfolders large icon """ obj = getattr(self, id) return obj.getLargeIcon() def getLargeIconById(self, id): """ returns subfolders large icon """ obj = getattr(self, id) return obj.getLargeIcon() def updatePortfolioContent(self): """ updates portfolio content """ for eport in self.Members.objectValues("Eportfolio"): eport.makePortfolioContent() def makePortfolioContent(self): """ creates all content to portfolio folder """ #XXX user's personal Blog if not hasattr(self, 'blog'): from Blog import BlogFolder blog = BlogFolder('blog') self._setObject(blog.id, blog) ob=getattr(self,blog.id) ob.setTitle('Blog') ob._setProperty('left_slots', [ 'here/portlet_eportfolio/macros/portlet', 'here/portlet_calendar/macros/portlet',], 'lines') ob._setProperty('right_slots', [ 'here/portlet_new_content/macros/portlet-additem', 'here/portlet_blog/macros/portlet-additem', 'here/portlet_blog/macros/portlet-blogroll', 'here/portlet_workflow/macros/portlet-workflow', 'here/portlet_reference_to_competencies/macros/portlet', 'here/portlet_blog/macros/tagcloud',], 'lines') ob.reindexObject() #XXX user's personal profile if not hasattr(self, 'profile'): from Profile import Profile profile = Profile('profile') self._setObject(profile.id, profile) ob=getattr(self,profile.id) ob.setTitle('Profile') ob._setProperty('left_slots', [ 'here/portlet_eportfolio/macros/portlet', 'here/portlet_calendar/macros/portlet',], 'lines') ob._setProperty('right_slots', ['here/portlet_profile/macros/portlet',], 'lines') ob.reindexObject() #XXX user's personal groups if not hasattr(self, 'groups'): from Groups import Groups groups = Groups('groups') self._setObject(groups.id, groups) ob=getattr(self,groups.id) ob.setTitle('Groups') ob._setProperty('left_slots', [ 'here/portlet_eportfolio/macros/portlet', 'here/portlet_calendar/macros/portlet',], 'lines') ob._setProperty('right_slots', [], 'lines') ob.reindexObject() #XXX user's personal competence if hasattr(self, 'competence'): self._delObject('competence') if not hasattr(self.aq_base, 'competency'): from Competence import CompetencyManager competence = CompetencyManager('competency') self._setObject(competence.id, competence) ob=getattr(self,competence.id) ob.setTitle('Competency Manager') ob._setProperty('left_slots', [ 'here/portlet_eportfolio/macros/portlet', 'here/portlet_calendar/macros/portlet',], 'lines') ob._setProperty('right_slots', [ 'here/portlet_competency/macros/portlet',], 'lines') ob.reindexObject() #XXX user's personal TaskManager if not hasattr(self, 'taskmanager'): from TaskManager import TaskManager taskmanager = TaskManager('taskmanager') self._setObject(taskmanager.id, taskmanager) ob=getattr(self,taskmanager.id) ob.setTitle('Task Manager') ob._setProperty('left_slots', [ 'here/portlet_eportfolio/macros/portlet', 'here/portlet_calendar/macros/portlet',], 'lines') ob._setProperty('right_slots', [ 'here/portlet_new_content/macros/portlet-additem', 'here/portlet_drawer/macros/portlet_links', 'here/portlet_reference_to_competencies/macros/portlet', 'here/portlet_tasks/macros/portlet-tasks',], 'lines') ob.reindexObject() #XXX user's personal drawer if not hasattr(self, 'drawer'): from Drawer import Drawer drawer = Drawer('drawer') self._setObject(drawer.id, drawer) ob=getattr(self,drawer.id) ob.setTitle('Drawer') ob._setProperty('left_slots', [ 'here/portlet_eportfolio/macros/portlet', 'here/portlet_calendar/macros/portlet',], 'lines') ob._setProperty('right_slots', [ 'here/portlet_new_content/macros/portlet-additem', 'here/portlet_workflow/macros/portlet-workflow', 'here/portlet_reference_to_competencies/macros/portlet', 'here/portlet_drawer/macros/portlet_links',], 'lines') ob.reindexObject() if not hasattr(self, 'dashboard'): from Dashboard import Dashboard dashboard = Dashboard('dashboard') self._setObject(dashboard.id, dashboard) ob=getattr(self,dashboard.id) ob.setTitle('Dashboard') ob._setProperty('left_slots', [ 'here/portlet_eportfolio/macros/portlet', 'here/portlet_calendar/macros/portlet',], 'lines') ob._setProperty('right_slots', [ 'here/portlet_tasks/macros/portlet-tasks', 'here/portlet_blog/macros/portlet-blogroll',], 'lines') ob.reindexObject() def getCategoryVocab(self): """ """ static_categories = ['Task','Goal','Self-estimate'] dynamic_categories = self.blog.getDynamicCategories() all_categories = static_categories + dynamic_categories all_categories.sort() return all_categories def amIOwner(self): """ check owner of object """ roles = self.portal_membership.getAuthenticatedMember().getRolesInContext(self) return 'Owner' in roles def getProducts(self): """ list of products """ member_id = self.getId() portal_catalog = getToolByName(self, 'portal_catalog') results = portal_catalog.searchResults() return [x.getObject() for x in results if x.meta_type in ['Presentation', 'File', 'ATFile', 'ATImage', 'Report'] and x.Creator in member_id] def getQcls(self): """ list of qcls """ member_id = self.getId() portal_catalog = getToolByName(self, 'portal_catalog') results = portal_catalog.searchResults() return [x.getObject() for x in results if x.meta_type in ['QCL'] and x.Creator in member_id] def getTasks(self): """ list tasks """ return self.blog.objectValues(['StructuredAnswer', 'ReflectionAnswer']) def getCompetencies(self): """ list comptencies """ competencies = [] hidden_list = self.competency.getHiddenList() for st in self.getCompetencyStandards(): if st.id not in hidden_list: competencies += [st] + self.getCompetenciesByStandard(st.id) return competencies def getCompetencyStandards(self): """standards""" portal_catalog = getToolByName(self, 'portal_catalog') results = portal_catalog.searchResults() return [x.getObject() for x in results if x.meta_type in ['CompetencyStandard']] def getCompetenciesByStandard(self, standard_id): """ list comptencies """ portal_catalog = getToolByName(self, 'portal_catalog') results = portal_catalog.searchResults() competencies = [] for x in results: if x.meta_type in ['CompetencyGroup'] and x.getCompetencyStandardId==standard_id: x_ob = x.getObject() if x_ob.objectValues('Competency'): competencies.append(x_ob) tmp = [] for x in competencies: tmp.append([x.aq_parent.getObjectPosition(x.getId()), x]) tmp.sort() res = [] for x in tmp: res.append(x[1]) return res def controlOwner(self, dashboard_obj): """ """ return dashboard_obj.getOwnerTuple()[1] registerType(Eportfolio, PROJECT_NAME)