# -*- coding: utf-8 # Copyright 2005 by Meelis Mets 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 BaseContent, registerType from Globals import InitializeClass from Products.CMFCore.utils import getToolByName from Permissions import * from AccessControl import ClassSecurityInfo, Unauthorized from config import PROJECT_NAME, MODULE_LIST schema = BaseSchema class TaskCollector(BaseContent): """ Template answers. """ meta_type = "TaskCollector" archetype_name = "TaskCollector" global_allow = 1 allowed_content_types = [] security = ClassSecurityInfo() content_icon='taskcollector_icon.gif' schema = schema actions = ( { 'id':'view', 'name':'View', 'action':'string:${object_url}/task_collector_view', 'permissions': ('View',), }, ) def getTasks(self, member): """ Tasks """ results = [] groupstool = getToolByName(self, 'portal_groups') groups = groupstool.listGroupIds() for target in groups: target2 = groupstool.getGroupById(target) for md in target2.getGroupMembers(): if md.id == str(member): query_string = {'SearchableText': {'operator': 'or', 'query': (str(target),)}} pcatalog = getToolByName(self, 'portal_catalog') for result in pcatalog.searchResults(query_string): results.append(result) return results def getRemoteUrl(self): return self.absolute_url() def getFullName(self, username): return self.portal_membership.getMemberById(username).fullname def getMyGr(self): """ Classes massive """ classes = [] member = str(self.REQUEST.AUTHENTICATED_USER) groupstool = getToolByName(self, 'portal_groups') groups = groupstool.listGroupIds() for target in groups: target2 = groupstool.getGroupById(target) for md in target2.getGroupMembers(): if md.id == member: classes.append(str(target)) return classes registerType(TaskCollector, PROJECT_NAME)