source: trunk/Tool.py @ 444

Revision 444, 2.3 KB checked in by jukka, 13 years ago (diff)

Worked on #442, spent 2h. Modified the default view for archetypes objects to be quite nice: If fields are empty, then field labels are not shown and for fields that are probably main body texts (iff WYSIWYMWidget) labels are not shown. Also simplified view page macros a lot; bundled about 5 metal-macros to one.

  • Property svn:eol-style set to native
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-1301  USA
18
19from Products.Archetypes.public import BaseSchema, Schema
20from Products.Archetypes.public import StringField, LinesField, TextField
21from Products.Archetypes.public import LinesWidget, TextAreaWidget, IdWidget, StringWidget, SelectionWidget, RichWidget
22from Products.Archetypes.public import BaseContent, registerType
23from SharedMetadata import bodytext, language_schema, tags, coverImage, lemill_metadata_mods, no_description, author_schema, license_schema
24from FieldsWidgets import TagsField
25from Globals import InitializeClass
26from Products.CMFCore.utils import getToolByName
27from AccessControl import ClassSecurityInfo, Unauthorized
28from config import PROJECTNAME
29from Resources import LearningResource
30
31homepage = Schema((
32    TextField('address',
33        default= "http://",
34        index="FieldIndex:schema",
35        searchable=True,
36        widget = StringWidget(
37            label="Homepage URL",
38            label_msgid="homepage_url",
39            description="URL to the tool's homepage",
40            i18n_domain="lemill"
41        ),
42    ),
43))
44
45schema = BaseSchema + bodytext + coverImage + tags + no_description + author_schema + homepage + language_schema + lemill_metadata_mods + license_schema
46
47for key in schema.keys():
48    schema[key].schemata = 'default'
49schema.moveField('bodyText', before='creators')   
50schema.moveField('language', after='address')
51schema.moveField('tags', after='language')
52
53class Tool(LearningResource):
54    schema = schema
55    meta_type = "Tool"
56    archetype_name = "Tool" 
57    security = ClassSecurityInfo()
58    security.declareObjectPublic()
59   
60registerType(Tool, PROJECTNAME)
Note: See TracBrowser for help on using the repository browser.