# -*- coding: utf-8 # Copyright 2006 by Meelis Mets from Products.Archetypes.public import BaseSchema, Schema from Products.Archetypes.public import BooleanField, FileField, StringField from Products.Archetypes.public import BooleanWidget, FileWidget, StringWidget, SelectionWidget from Products.Archetypes.public import BaseContent, registerType from Globals import InitializeClass from Products.CMFCore.utils import getToolByName from AccessControl import ClassSecurityInfo, Unauthorized from config import PROJECT_NAME from BaseTest import BaseTask schema = BaseTask.schema + Schema(( FileField('soundFile', accessor = 'getSoundFile', required = 1, widget = FileWidget( label = 'Sound file', description = 'Upload sound file here', label_mgsid = 'label_sound_file', description_msgid = 'desc_sound_file', i18n_domain = 'psyhvel', visible = {'view':'invisible', 'edit':'visible'} ), ), BooleanField('autoPlay', accessor = 'getAutoPlay', widget = BooleanWidget( label = 'Play sound automatically', description = 'If not checked sound will wait for clicking PLAY', label_msgid="label_auto_play", description_msgid="desc_auto_play", i18n_domain="psyhvel", visible = {'view': 'invisible', 'edit':'visible'}, ), ), StringField('tableWidth', accessor = 'getTableWidth', vocabulary = 'getNumbers', default = '5', widget = SelectionWidget( format = 'select', label = 'Table width', label_msgid='label_table_width', description = 'How many objects are in table by horizontally', description_msgid = 'desc_table_width', i18n_domain="psyhvel", visible = {'view': 'invisible', 'edit':'visible'}, ), ), StringField('tableHeight', accessor = 'getTableHeight', vocabulary = 'getNumbers', default = '1', widget = SelectionWidget( format = 'select', label = 'Table height', label_msgid='label_table_height', description = 'How many objects are in table by vertically', description_msgid = 'desc_table_height', i18n_domain="psyhvel", visible = {'view': 'invisible', 'edit':'visible'}, ), ), BooleanField('tableHasBorder', accessor = 'getTableHasBorder', widget = BooleanWidget( label = 'Objects in table have border', label_msgid='label_table_has_border', description = 'Check if you want to add border to objects', description_msgid = 'desc_table_has_border', i18n_domain="psyhvel", visible = {'view': 'invisible', 'edit':'visible'}, ), ), )) class SoundTask(BaseTask): """ Sound task""" meta_type = "SoundTask" archetype_name = "Sound Task" global_allow = 0 exclude_from_nav = True filter_content_types = True allowed_content_types = ('ChoiceObject',) security = ClassSecurityInfo() schema = schema actions = ( { 'id':'view', 'name':'View', 'action':'string:${object_url}/sound_task', 'permissions': ('View',), }, { 'id':'edit', 'name':'Configuration', 'action':'string:${object_url}/base_edit', 'permissions': ('Modify portal content',), }, { 'id':'choices', 'name':'Choices', 'action':'string:${object_url}/objects_view', 'permissions': ('Modify portal content',), }, { 'id':'metadata', 'name':'Info', 'action':'string:${object_url}/base_metadata', 'permissions': ('Modify portal content',), }, ) def getObjectsXML(self, files): """special xml""" xml = self.getBaseXML() snd = self.getField('soundFile') fname = snd.getFilename(self) soundfile = snd.getBaseUnit(self) xml += '\n' xml += '\n' xml += '\n' xml += '\n' xml += '\n' xml += '\n' xml += '\n' xml += '\n' xml += '\n' xml += '' files.append({'filename':fname, 'file':str(soundfile)}) return [xml, files] registerType(SoundTask, PROJECT_NAME)