from Products.Archetypes.public import BaseSchema, Schema from Products.Archetypes.public import StringField, LinesField from Products.Archetypes.public import LinesWidget, TextAreaWidget, IdWidget, StringWidget #from Products.Archetypes.public import BaseFolder, registerType from Products.Archetypes.public import OrderedBaseFolder, registerType from Products.CMFCore import CMFCorePermissions from config import VIEW_CONTENTS_PERMISSION from Products.CMFPlone.interfaces.OrderedContainer import IOrderedContainer from UpDownMixin import UpDownMixin schema = BaseSchema + Schema(( StringField('id', required=0, ## Still actually required, but ## the widget will supply the missing value ## on non-submits mode="rw", accessor="getId", mutator="setId", isMetadata=1, default=None, widget=IdWidget( label="ID", label_msgid='label_id', description="Should not contain spaces, underscores or mixed case. ID is part of the item's web address.", description_msgid='desc_id', visible={'view' : 'visible'}, i18n_domain="curriculum"), ), StringField('title', required=1, searchable=1, isMetadata=1, default='', accessor='Title', widget=StringWidget( label_msgid='label_title', description_msgid='help_title', i18n_domain="curriculum"), ), StringField('description', isMetadata=1, accessor='Description', widget=TextAreaWidget( label='Description', label_msgid='label_description', description='Give a description for this Curriculum.', description_msgid='desc_description', i18n_domain="curriculum"), ), StringField('indextitle', isMetadata=1, accessor='IndexTitle', widget=StringWidget( label='Index Title', label_msgid='label_indextitle', description='Give a title for this Index of contents.', description_msgid='desc_indextitle', i18n_domain="curriculum"), ), )) class Curriculum(OrderedBaseFolder, UpDownMixin): """ A folder object to store Curriculum in """ meta_type = "Curriculum" archetype_name = 'Curriculum' allowed_content_types=('Chapter', 'Link', 'Image', 'File', 'Portlet') filter_content_types=1 global_allow=1 __implements__ = (OrderedBaseFolder.__implements__, IOrderedContainer) schema=schema content_icon='curriculum_icon.gif' actions = ({ 'id': 'view', 'name': 'View', 'action': 'string:${object_url}/curriculum_view', 'permissions': (VIEW_CONTENTS_PERMISSION,) }, # {'id': 'Contents', # 'name': 'Contents', # 'action': 'string:${object_url}/folder_contents', # 'permissions': (VIEW_CONTENTS_PERMISSION,) # }, {'id': 'Print', 'name': 'Print', 'action': 'string:${object_url}/curriculum_print', 'permissions': (VIEW_CONTENTS_PERMISSION,) },) def chap2(self, chap, result, nr, trepp): """ Sisukorra loomiseks """ i = 1 for chapt in chap.objectValues('Chapter'): number = nr + str(i) + "." result.append(number) result.append(chapt) if (trepp == 'treppida'): number = "   " + number self.chap2(chapt, result, number, trepp) i = i + 1 return result def getToc(self, trepp): """ Sisukorra loomiseks """ result = [] i = 1 for chap in self.objectValues('Chapter'): number = str(i) + "." result.append(number) result.append(chap) if (trepp == 'treppida'): number = "   " + number self.chap2(chap, result, number, trepp) i = i + 1 return result def nr2(self, chap, result, nr, test): """ Sisukorra loomiseks """ i = 1 for chapt in chap.objectValues('Chapter'): number = nr + str(i) + "." if (test == chapt.Title()): result = number break else: result = self.nr2(chapt, result, number, test) i = i + 1 return result def getNr(self, test): """ Sisukorra loomiseks """ result = "puudu" i = 1 for chap in self.objectValues('Chapter'): number = str(i) + "." if (test == chap.Title()): result = number else: result = self.nr2(chap, result, number, test) i = i + 1 return result registerType(Curriculum)