def canEnable(self):
     """Test if the user can enable the map on the current content.
     You can't enable the viewlet if the content has no Location
     """
     context = self.context
     return self._getUser().has_permission('Enable Monet Googlemaps viewlet', self.context) \
             and not IMonetMapsEnabledContent.providedBy(context)
 def test_ownerCanDisableMap(self):
     self.login('contributor1')
     page = self.createPage('p1')
     page.restrictedTraverse('@@monet.gmap').enable()
     self.assertTrue(IMonetMapsEnabledContent.providedBy(page))
     self.assertTrue(self.getMember().has_permission('Enable Monet Googlemaps viewlet', page))
     self.assertFalse(page.restrictedTraverse('@@monet.gmap').canEnable())
     self.assertTrue(page.restrictedTraverse('@@monet.gmap').canDisable())
Example #3
0
 def canShowMap(self):
     """Return true if we are in the edit view of the content"""
     context = self.context
     context_state = getMultiAdapter((context, self.request), name=u'plone_context_state')
     isViewTemplate = context_state.is_view_template()
     return not isViewTemplate and IMonetMapsEnabledContent.providedBy(context)
 def canDisable(self):
     """Check if the user can disable the map"""
     return self._getUser().has_permission('Enable Monet Googlemaps viewlet', self.context) and \
             IMonetMapsEnabledContent.providedBy(self.context)