source: trunk/MultimediaMaterial.py @ 1983

Revision 1864, 3.3 KB checked in by jukka, 12 years ago (diff)

Oops, one thing was not saved before last commit.

Line 
1# Copyright 2006 by the LeMill Team (see AUTHORS)
2#
3# This file is part of LeMill.
4#
5# LeMill is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# LeMill is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with LeMill; if not, write to the Free Software
17# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1
18
19from AccessControl import ClassSecurityInfo, getSecurityManager
20from Products.Archetypes.public import *
21from Products.CMFCore.utils import getToolByName
22
23from config import PROJECTNAME, MODIFY_CONTENT, VIEW
24from FieldsWidgets import ChapterField, ChapterWidget, StringWidget
25from SharedMetadata import *
26from Material import Material
27from permissions import MODIFY_CONTENT
28import re
29
30schema = BaseSchema + Schema((
31   ChapterField('bodyText',
32        accessor="getBodyText",
33        edit_accessor = 'getRawBodyText',
34        mutator = "setBodyText",
35        index='ZCTextIndex:schema',
36        index_method = 'getOnlyText',
37        searchable = True,
38        allowable_content_types = ['text/html',],
39        allow_file_upload = False,
40        default_output_type = 'text/x-html-captioned',
41        default_content_type = 'text/html',
42        widget=ChapterWidget(label = "Body text",
43            label_msgid = "label_bodytext",
44            i18n_domain = "lemill",
45            ),
46    ),
47))
48
49schema = schema + tags + language_schema + group_sharing + subject_area_schema + target_group_schema + license_schema + coverImage + lemill_metadata_mods + no_description + author_schema + deletionReason + version_schema + translation_schema + ieee_lom_lre_ap + latest_edit_schema + score
50
51schema = schema.copy()
52schema.moveField('rights', pos='bottom')
53schema.moveField('language', after='bodyText')
54schema['title'].required = True
55
56
57class MultimediaMaterial(Material):
58    """Multimedia page"""
59
60    schema = schema
61
62    meta_type = "MultimediaMaterial"
63    archetype_name = "MultimediaMaterial"
64
65    security = ClassSecurityInfo()
66    security.declareObjectPublic()
67
68    security.declarePrivate('manage_afterAdd')
69    def manage_afterAdd(self, item, container):
70        Material.manage_afterAdd(self, item, container)
71
72        if not hasattr(item.aq_base, 'left_slots'):
73            self._setProperty('left_slots', ['here/portlet_material_actions/macros/portlet',], 'lines')
74        else:
75            self._updateProperty('left_slots', ['here/portlet_material_actions/macros/portlet',])
76
77    def getOnlyText(self):
78        field=self.getField('bodyText')
79        values = field.get(self)
80        dump= '\n'.join([x for x in values if not field.isUid(x)])
81        return dump
82
83    security.declareProtected(MODIFY_CONTENT,'delChapter')
84    def delChapter(self, REQUEST):
85        """ delete chapter """
86        field = self.getField('bodyText')
87        field.delChapter(self, int(REQUEST.get('delete')))
88        return REQUEST.RESPONSE.redirect(self.absolute_url()+'/edit')
89
90registerType(MultimediaMaterial, PROJECTNAME)
Note: See TracBrowser for help on using the repository browser.