1 | from AccessControl import ClassSecurityInfo |
---|
2 | try: |
---|
3 | from Products.CMFCore.permissions import ModifyPortalContent, View |
---|
4 | except ImportError: |
---|
5 | from Products.CMFCore.CMFCorePermissions import ModifyPortalContent, View |
---|
6 | |
---|
7 | try: |
---|
8 | from Products.LinguaPlone.public import * |
---|
9 | except ImportError: |
---|
10 | from Products.Archetypes.public import * |
---|
11 | |
---|
12 | from Products.ATContentTypes.content.base import ATCTContent |
---|
13 | from Products.ATReferenceBrowserWidget.ATReferenceBrowserWidget import ReferenceBrowserWidget |
---|
14 | |
---|
15 | from Products.qPloneGoogleMaps.config import PROJECTNAME |
---|
16 | |
---|
17 | OverlaySchema = 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 | |
---|
47 | class 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 | |
---|
82 | registerType(Overlay, PROJECTNAME) |
---|