source: trunk/Activity.py @ 1906

Revision 1906, 2.5 KB checked in by jukka, 13 years ago (diff)

Closed #1475. Groups still refer to these as 'learning resources', we'll clean those page templates when resource-based discussions are added.

  • 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 SharedMetadata import *
20from Products.Archetypes.public import *
21from Products.Archetypes.atapi import DisplayList
22from Globals import InitializeClass
23from Products.CMFCore.utils import getToolByName
24from AccessControl import ClassSecurityInfo, Unauthorized
25from config import PROJECTNAME
26from Resources import LearningResource
27
28from Tool import homepage
29
30schema = BaseSchema + bodytext + coverImage + tags + group_sharing + no_description + homepage + author_schema + language_schema + license_schema + lemill_metadata_mods + deletionReason + translation_schema + latest_edit_schema + score + Schema((
31
32    FileField('video',
33        widget = FileWidget(
34            label="Video",
35            description="Upload a video if available.",
36            i18n_domain="lemill",
37            label_msgid='label_video',
38            description_msgid='help_video',
39            show_content_type= True,
40        ),
41    ),
42))
43
44schema = schema.copy()
45for key in schema.keys():
46    schema[key].schemata = 'default'
47schema.moveField('bodyText', before='creators')
48schema.moveField('language', after='address')
49schema.moveField('tags', after='language')
50schema.moveField('groups', after='tags')
51schema.moveField('rights', pos='bottom')
52
53
54class Activity(LearningResource):
55    schema = schema
56    meta_type = "Activity"
57    archetype_name = "Activity"
58
59    def getRelatedStories(self):
60        """ Returns good collections with stories """
61        pc = getToolByName(self, 'portal_catalog')
62        query = {'getRawRelatedMethods':self.UID(),
63            'getGoodStory':True,
64            'meta_type':'Collection',
65            'sort_on':'Date',
66            'sort_order':'descending'}
67        results = pc.searchResults(query)
68        results = [x for x in results if x.review_state!='deleted']
69        return results
70
71registerType(Activity, PROJECTNAME)
Note: See TracBrowser for help on using the repository browser.