source: products/qPloneGoogleMaps/tags/0.1.0/content/Overlay.py

Last change on this file was 1, checked in by myroslav, 18 years ago

Building directory structure

  • Property svn:eol-style set to native
File size: 2.9 KB
Line 
1from AccessControl import ClassSecurityInfo
2try:
3    from Products.CMFCore.permissions import ModifyPortalContent, View
4except ImportError:
5    from Products.CMFCore.CMFCorePermissions import ModifyPortalContent, View
6
7try:
8  from Products.LinguaPlone.public import *
9except ImportError:
10  from Products.Archetypes.public import *
11
12from Products.ATContentTypes.content.base import ATCTContent
13from Products.ATReferenceBrowserWidget.ATReferenceBrowserWidget import ReferenceBrowserWidget
14
15from Products.qPloneGoogleMaps.config import PROJECTNAME
16
17OverlaySchema = BaseSchema.copy() + Schema((
18    ReferenceField('markerssource',
19                   accessor = 'getSource',
20                   required = True,
21                   multiValued=0,
22                   allowed_types=('Folder', 'Topic', 'Large Plone Folder'),
23                   relationship='markers',
24                   widget=ReferenceBrowserWidget(label='Markers Source',
25                                                 label_msgid='label_markers_source',
26                                                 allow_search=1,
27                                                 allow_browse=1,
28                                                 startup_directory='/',
29                                                 show_path=1,
30                                                 description='Select source object for Markers.',
31                   )
32    ),
33    StringField('markerscolor',
34        accessor = 'getMarkersColor',
35        vocabulary=('default', 'red', 'green', 'blue'),
36        default='default',
37        widget=SelectionWidget(
38            label='Markers Color',
39            label_msgid='label_markers_color',
40            description_msgid='help_markers_color',
41            i18n_domain='googlemaps',
42        )
43    ),
44))
45
46
47class Overlay(ATCTContent):
48    """ Maps Overlay """
49
50    schema          = OverlaySchema
51
52    content_icon    = 'overlay_icon.gif'
53    portal_type     = 'Overlay'
54    meta_type       = 'Overlay'
55    archetype_name  = 'Overlay'
56    default_view    = 'overlay_view'
57    immediate_view  = 'overlay_view'
58    suppl_views     = ()
59    typeDescription = 'Maps Overlay'
60    typeDescMsgId   = 'overlay_description_edit'
61
62    global_allow    = 0
63
64    security       = ClassSecurityInfo()
65
66    # Get the standard actions (tabs)
67    #actions = ATCTContent.actions
68
69    # Make sure we get title-to-id generation when an object is created
70    _at_rename_after_creation = True
71
72    security.declareProtected(View, 'getMarkers')
73    def getMarkers(self):
74        """ Get object or brains with geolocation properties from source object """
75        container = self.getSource()
76        if container and container.portal_type:
77            contentsMethod = container.getFolderContents
78            if container.portal_type == 'Topic': contentsMethod = container.queryCatalog
79            return [el for el in contentsMethod() if el.geoLocation]
80        return []
81
82registerType(Overlay, PROJECTNAME)
Note: See TracBrowser for help on using the repository browser.