source: trunk/Tool.py @ 2417

Revision 2410, 3.2 KB checked in by anonymous, 11 years ago (diff)

Portlets are much more efficient and simpler now and work independent of Plone's portlet system. The logic is in Resources/getPortletDetails, portlets itself just either show or not show their parts.

  • 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, deletionReason, translation_schema, latest_edit_schema, score, group_sharing, state
24from FieldsWidgets import TagsField, HTMLLinkWidget
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 = HTMLLinkWidget(
37            label="Homepage URL",
38            label_msgid="label_homepage_url",
39            description="URL to the homepage",
40            description_msgid="decription_homepage_url",
41            i18n_domain="lemill"
42        ),
43    ),
44))
45
46schema = BaseSchema + bodytext + coverImage + tags + group_sharing + no_description + author_schema + homepage + language_schema + lemill_metadata_mods + license_schema + deletionReason + translation_schema + latest_edit_schema + score + state
47
48# ALWAYS schema.copy before making changes to fields.
49# The fields from ShareMetadata are shared by all schema.
50
51schema=schema.copy()
52
53for key in schema.keys():
54    schema[key].schemata = 'default'
55schema.moveField('bodyText', before='creators')   
56schema.moveField('language', after='address')
57schema.moveField('tags', after='language')
58schema.moveField('groups', after='tags')
59schema.moveField('rights', pos='bottom')
60
61class Tool(LearningResource):
62    schema = schema
63    meta_type = "Tool"
64    archetype_name = "Tool" 
65    portlet = 'here/portlet_tool_actions/macros/portlet'
66    security = ClassSecurityInfo()
67    security.declareObjectPublic()
68
69    def getRelatedStories(self):
70        """ Returns good collections with stories """
71        pc = getToolByName(self, 'portal_catalog')
72        query = {'getRawRelatedTools':self.UID(),
73            'getGoodStory':True,
74            'meta_type':'Collection',
75            'sort_on':'getLatestEdit',
76            'sort_order':'descending',
77            'getState':'public'}
78        return pc.searchResults(query)
79   
80registerType(Tool, PROJECTNAME)
Note: See TracBrowser for help on using the repository browser.