# -*- coding: utf-8 # Copyright 2006 by Meelis Mets from Products.Archetypes.public import BaseSchema, Schema from Products.Archetypes.public import TextField from Products.Archetypes.public import TextAreaWidget from Products.Archetypes.public import OrderedBaseFolder, BaseContent, registerType from Globals import InitializeClass from Products.CMFCore.utils import getToolByName from Products.CMFCore.permissions import View, ModifyPortalContent from AccessControl import ClassSecurityInfo, Unauthorized from config import PROJECT_NAME, TASK_TYPES, BLOG_TYPES from Common import CommonMix schema = BaseSchema class GroupNote(BaseContent, CommonMix): """ GroupNote""" meta_type = "GroupNote" archetype_name = "Group Note" global_allow = 0 exclude_from_nav = True filter_content_types = True allowed_content_types = () security = ClassSecurityInfo() schema = schema + Schema(( TextField('groupnote', accessor='getGroupnote', widget = TextAreaWidget( label="Note", description="", label_msgid='label_note', description_msgid='description_note', visible={'view':'visible','edit':'visible'}, i18n_domain="eportfolio", ), ), )) actions = ( { 'id':'view', 'name':'View', 'action':'string:${object_url}/base_view', 'permissions': ('View',), }, { 'id':'edit', 'name':'Edit', 'action':'string:${object_url}/base_edit', 'visible':False, }, { 'id':'metadata', 'visible':False, }, ) registerType(GroupNote, PROJECT_NAME) class GroupNoteFolder(OrderedBaseFolder, CommonMix): """ GroupNoteFolder""" meta_type = "GroupNoteFolder" archetype_name = "Group Note Folder" global_allow = 0 exclude_from_nav = True filter_content_types = True allowed_content_types = ('GroupNote',) security = ClassSecurityInfo() schema = schema actions = ( { 'id':'view', 'name':'View', 'action':'string:${object_url}/security_view', 'permissions': ('View',), }, { 'id':'edit', 'name':'Edit', 'action':'string:${object_url}/base_edit', 'visible':False, }, { 'id':'metadata', 'visible':False, }, ) #def manage_afterAdd(self,item,container): # """sets permissions""" # setupPermissionsHere() security.declareProtected('Manage Portal', 'setupPermissionsHere') def setupPermissionsHere(self): """group notes dd""" self.manage_permission('View', ('Owner',) ,0) self.manage_permission('Modify portal content', ('Manager','Moderator',) ,0) security.declareProtected(View, 'getGroupNotes') def getGroupNotes(self): """group notes""" notes = self.objectValues('GroupNote') notes.reverse() return notes security.declareProtected(ModifyPortalContent, 'addGroupNote') def addGroupNote(self, note_id, note_title, note_note): """add group note""" if hasattr(self, note_id): nid = note_id else: import time newId = 'note-'+str(time.time()).replace('.','') nid = self.invokeFactory("GroupNote", id=newId, title=note_title) res = ["new",newId,note_title,note_note] obj = getattr(self, nid) obj.title = note_title obj.groupnote = note_note return self.REQUEST.RESPONSE.redirect(self.aq_parent.absolute_url()) security.declareProtected(ModifyPortalContent, 'delGroupNote') def delGroupNote(self,note_id): """del group note""" if hasattr(self,note_id): self._delObject(note_id) return self.REQUEST.RESPONSE.redirect(self.aq_parent.absolute_url()) registerType(GroupNoteFolder, PROJECT_NAME)