# -*- coding: utf-8 # Copyright 2006 by Meelis Mets from Products.Archetypes.public import BaseSchema, Schema from Products.Archetypes.public import FileField, TextField, ReferenceField from Products.Archetypes.public import FileWidget, RichWidget from Products.ATReferenceBrowserWidget.ATReferenceBrowserWidget import ReferenceBrowserWidget from Products.Archetypes.public import BaseContent, registerType from Globals import InitializeClass from Products.CMFCore.utils import getToolByName from Products.Archetypes.public import RFC822Marshaller from Products.Archetypes.public import AnnotationStorage from AccessControl import ClassSecurityInfo, Unauthorized from config import PROJECT_NAME schema = BaseSchema + Schema(( TextField('text', accessor='getBody', required=True, searchable=True, primary=True, storage = AnnotationStorage(migrate=True), validators = ('isTidyHtmlWithCleanup',), #validators = ('isTidyHtml',), default_content_type = 'Sheet', default_output_type = 'text/x-html-safe', allowable_content_types = (), widget = RichWidget( description = "", description_msgid = "help_slide_body", label = "Slide body", label_msgid = "label_slide_body", rows = 25, i18n_domain = "eportfolio", allow_file_upload = 0)), ReferenceField('refsToLinks', accessor = 'getRefsToLinks', relationship = 'References', mutator = 'addRefsToLinks', allowed_types = ('Drawer','File','Image'), multiValued = True, widget = ReferenceBrowserWidget( force_close_on_insert = True, startup_directory = "drawer", label = "Related links", label_msgid = "label_related_links", i18n_domain = "eportfolio", visible = {'view':'visible', 'edit':'visible'},) ), ), marshall=RFC822Marshaller() ) class Sheet(BaseContent): """ E-Portfolio Slide""" meta_type = "Sheet" archetype_name = "Sheet" global_allow = 0 exclude_from_nav = True filter_content_types = True allowed_content_types = () security = ClassSecurityInfo() schema = schema actions = ( { 'id':'view', 'name':'View', 'action':'string:${object_url}/base_view', 'permissions': ('View',), }, { 'id':'edit', 'name':'Edit', 'action':'string:${object_url}/base_edit', 'permissions': ('Access Denied',), }, { 'id':'metadata', 'name':'Properties', 'action':'string:${object_url}/base_metadata', 'permissions': ('Access Denied',), }, ) def __init__(self, id): self.id = id self.largeIcon = "presentation.gif" #def manage_afterAdd(self,item,container): def getAct(self): """ACT""" action = {'action': 'string:${object_url}/drawer_view', 'permissions': ('View',), 'id': 'esimene', 'name': 'Esimene'} act = getattr(self.aq_parent, 'actions') act = act + (action,) setattr(self.aq_parent, 'actions', act) return self.aq_parent.actions registerType(Sheet, PROJECT_NAME)