# -*- coding: utf-8 # Copyright 2005 by Vahur Rebas from Products.Archetypes.public import BaseFolderSchema, Schema from Products.Archetypes.public import BaseFolder from Products.Archetypes.public import registerType from Products.CMFCore.utils import getToolByName from AccessControl import ClassSecurityInfo from config import PROJECT_NAME schema = BaseFolderSchema class ProgressClassFolder(BaseFolder): """ This folder holds all progress interviews. """ meta_type = "ProgressClassFolder" archetype_name = "ProgressClassFolder" allowed_content_types = [] filter_content_types = 1 global_allow = 0 exclude_from_nav = False security = ClassSecurityInfo() schema = schema actions = ( { 'id': 'view', 'name': 'View', 'action': 'string:${object_url}/prog_class_view', 'permissions': ('View phase content',), }, { 'id': 'folderlisting', 'name': 'Folder Listing', 'action': 'string:${object_url}/prog_class_view', 'permissions': ('View phase content',), }, ) def getStudents(self): """ returs a list of classes(groups) """ group = self.prefs_user_group_search(self.title, 'groups') group = group[0] return group.getGroupMembers() def checkUserFolder(self, user): """ creates user folder is doesn't exist. """ x = getattr(self.aq_self, str(user), None) if not x: typestool = getToolByName(self, 'portal_types') puf_type = getattr(typestool, 'ProgressClassFolder', None) if not puf_type: return 0 puf_type.allowed_content_types = ("ProgressUserFolder") id = self.invokeFactory('ProgressUserFolder', str(user), title=user.getProperty('fullname')) puf_type.allowed_content_types = [] return 1 def getNextStep(self, user): """ fail safe. real method in ProgressUserFolder class """ # do ProgressUserFolder checking return self def getPhase(self, phase, user): """ fail safe. real method in ProgressUserFolder class """ # get phase object. return self def getProgUserFolder(self, user): """ return ProgressUserFolder class object if fails, return self """ self.checkUserFolder(user) return getattr(self, str(user), self) registerType(ProgressClassFolder, PROJECT_NAME)