# -*- coding: utf-8 # Copyright 2007 by Vahur Rebas from AccessControl import ClassSecurityInfo from Products.Archetypes.public import BaseSchema, Schema from Products.Archetypes.public import BaseContent from Products.Archetypes.public import registerType from Products.Archetypes.public import StringField, TextAreaWidget from Common import CommonMix as Common from StructuredTask import StructuredWidgetFunctions from BaseTask import linksWidgetFunctions from Widgets import StructuredTaskWidget, DictField from config import PROJECT_NAME schema = BaseSchema.copy() + Schema(( StringField('help', widget=TextAreaWidget( label="Help text", description="Add help text here, this text should describe how to fill form or something like that", label_msgid='label_help', description_msgid='help_desc', i18n_domain="eportfolio"), ), DictField('datafields', accessor='getDatafields', mutator='setDatafields', widget=StructuredTaskWidget( label='Fields', label_msgid='label_datafields', description='Data fields', description_msgid='help_datafields', visible={'view':'visible','edit':'invisible'}, i18n_domain="eportfolio" ), ), )) class StructuredTemplate(BaseContent, Common, StructuredWidgetFunctions, linksWidgetFunctions): """ Structured Template """ meta_type = "StructuredTemplate" archetype_name = "StructuredTemplate" global_allow = 0 security = ClassSecurityInfo() security.declareObjectPublic() schema = schema actions = ( { 'id':'view', 'name':'View', 'action':'string:${object_url}/task_preview', 'permissions': ('View',), }, { 'id':'edit', 'name':'Edit', 'action':'string:${object_url}/base_edit', 'permissions': ('Edit Task',), }, { 'id':'metadata', 'visible':False, }, { 'id':'create', 'name':'Add question', 'action':'string:${object_url}/app_edit', 'permissions': ('Edit Task',), }, ) def __init__(self, id, **kwargs): BaseContent.__init__(self, id, **kwargs) self.id = id self.appFields = [] def manage_afterAdd(self, item, container): BaseContent.manage_afterAdd(self, item, container) self._setProperty('right_slots', ['here/portlet_new_content/macros/portlet-additem', 'here/portlet_workflow/macros/portlet-workflow', 'here/portlet_drawer/macros/portlet_links'], 'lines') def getFields(self): """ get Fields """ return self.appFields def getValue(self, fid): """returns space because task has no answers;)""" return "" def isTask(self): return True registerType(StructuredTemplate, PROJECT_NAME)