root/trunk/LeMillPrintResource.py

Revision 2979, 3.3 kB (checked in by jukka, 2 years ago)

Fixed few issues.

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
19 from AccessControl import ClassSecurityInfo
20 from Products.Archetypes.public import *
21 from Products.CMFCore.utils import getToolByName
22
23 from config import PROJECTNAME, MODIFY_CONTENT, VIEW, FS_STORAGE
24 from Material import Material
25 from Schemata import material_schema, license_schema
26 if FS_STORAGE:
27     from Products.FileSystemStorage.FileSystemStorage import FileSystemStorage
28 else:
29     from Products.Archetypes.Storage import AttributeStorage as FileSystemStorage
30
31 lemillprintresource_schema= Schema((
32     StringField('author',
33         widget = StringWidget(
34             label = 'Author',
35             label_msgid = 'label_author',
36             description = 'Author of this resource',
37             description_msgid = 'description_author',
38             i18n_domain = 'lemill',
39         ),
40     ),
41     FileField('file',
42         required=True,
43         storage=FileSystemStorage(),
44         widget = FileWidget(
45             label="PDF resource",
46             description="Allowed file types: .pdf",
47             i18n_domain="lemill",
48             label_msgid='label_pdf_file',
49             description_msgid='help_pdf_file',
50             show_content_type= True,
51         ),
52     ),
53 ))
54
55 schema = material_schema + license_schema + lemillprintresource_schema
56
57 schema = schema.copy()
58 # These widgets should be hidden
59 toBeHidden = ['bodyText', 'creators']
60 for x in schema.keys():
61     schema[x].schemata = 'default'
62     schema[x].isMetadata = False
63     if x in toBeHidden:
64         schema[x].widget.visible = {'view': 'invisible', 'edit':'invisible'}
65     if x == 'description':
66         schema[x].widget.visible = {'view': 'visible', 'edit':'visible'}
67 schema.moveField('file', after='title')
68 schema.moveField('author', after='file')
69 schema.moveField('description', after='author')
70 schema.moveField('tags', after='description')
71 schema.moveField('rights', pos='bottom')
72
73 class LeMillPrintResource(Material):
74     """ Reference to external resource """
75
76     schema = schema
77    
78     meta_type = 'LeMillPrintResource'
79     archetype_name = 'LeMillPrintResource'
80     default_location = 'content/printresources'
81
82     portlet = 'here/portlet_lemillprintresource_actions/macros/portlet'
83     security = ClassSecurityInfo()
84     security.declareObjectPublic()
85
86     aliases = {
87         '(Default)' : 'base_view',
88         'view'      : 'base_view',
89         'edit'      : 'base_edit'
90     }
91
92     def amIMaterial(self):
93         """ references are not proper material"""
94         return False
95
96     def hasComplexWorkflow(self):
97         """ Can have drafts or versions """
98         return False
99
100
101 registerType(LeMillPrintResource, PROJECTNAME)
Note: See TracBrowser for help on using the browser.