def checkReviewerRole(self): """ Checks if the 'Reviewer' role exists, creates and adds review permissions if it doesn't exist """ auth_tool = self.getAuthenticationTool() roles = auth_tool.list_all_roles() PERMISSION_GROUP = 'Review content' if 'Reviewer' not in roles: auth_tool.addRole('Reviewer', [PERMISSION_REVIEW_CONSULTATION]) else: permission_add_role(self, PERMISSION_REVIEW_CONSULTATION, 'Reviewer') #give permissions to administrators admin_permissions = self.permissionsOfRole('Administrator') site = self.getSite() if PERMISSION_MANAGE_CONSULTATION not in admin_permissions: site.manage_permission(PERMISSION_MANAGE_CONSULTATION, ('Administrator', ), acquire=1) site.manage_permission(PERMISSION_VIEW_CONSULTATION, ('Administrator', ), acquire=1) site.manage_permission(PERMISSION_REVIEW_CONSULTATION, ('Administrator', ), acquire=1)
def afterSetUp(self): permission_add_role(self.portal, 'Naaya - Skip Captcha', 'contributor') addNyNews(self.portal.info, submitted=1, title=news_data['news_title'], contributor='contributor') transaction.commit() self.login_user('admin', '') self.selenium_add_language('fr')
def test_ok(self): permission_add_role(self.portal, PERMISSION_DELETE_OBJECTS, 'Owner') self.login('contributor') ob = self._submit_obj() self.portal.restrictedTraverse('info/testurl/deleteThis')
def test_submit_by_contributor_with_auto_approve(self): permission_add_role(self.portal, PERMISSION_SKIP_APPROVAL, "Contributor") self.login("contributor") ob = self._submit_obj() self.assertEqual(ob.approved, 1) self.assertEqual(ob.submitted, 1) self.assertTrue(self.notify_maintainer.call_count, 1)
def _update(self, portal): permission = "Naaya - Create user" p = Permission(permission, (), portal) if 'Administrator' not in p.getRoles(): permission_add_role(portal, permission, 'Administrator') permission_add_role(portal, permission, 'Anonymous') self.log.debug('Added %s permission', permission) return True
def _update(self, portal): permissions = ["Naaya - Add Naaya Photo Folder", "Naaya - Add Naaya Photo Gallery"] for permission in permissions: p = Permission(permission, (), portal) if "Administrator" not in p.getRoles(): permission_add_role(portal, permission, "Administrator") self.log.debug("Added %s permission", permission) return True
def _update(self, portal): permission = "Naaya - Create user" p = Permission(permission, (), portal) if "Administrator" not in p.getRoles(): permission_add_role(portal, permission, "Administrator") permission_add_role(portal, permission, "Anonymous") self.log.debug("Added %s permission", permission) return True
def test_submit_by_contributor_with_auto_approve(self): permission_add_role(self.portal, PERMISSION_SKIP_APPROVAL, 'Contributor') self.login('contributor') ob = self._submit_obj() self.assertEqual(ob.approved, 1) self.assertEqual(ob.submitted, 1) self.assertTrue(self.notify_maintainer.call_count, 1)
def _update(self, portal): permissions = ["Naaya - Add Naaya Photo Folder", "Naaya - Add Naaya Photo Gallery"] for permission in permissions: p = Permission(permission, (), portal) if 'Administrator' not in p.getRoles(): permission_add_role(portal, permission, 'Administrator') self.log.debug('Added %s permission', permission) return True
def test_delete_by_checking(self): """ test can delete own object by ticking checkbox in folder view """ parent = self.portal['info'] permission_add_role(self.portal, PERMISSION_DELETE_OBJECTS, 'Owner') self.login('contributor') ob = self._submit_obj() ob_id = ob.getId() self.assertTrue(ob_id in parent.objectIds()) parent.deleteObjects(id=ob_id) self.assertTrue(ob_id not in parent.objectIds())
def selenium_initialize(self): portal = self.portal from naaya.core.zope2util import permission_add_role permission_add_role(portal, 'Naaya - Skip Captcha', 'contributor') transaction.commit() self.login_user('admin', '') self.selenium_add_language('fr') self.logout_user() self.login_user('contributor', 'contributor') self.selenium_add_news(news_data) #insert news as contributor self.logout_user() #logout contributor self.login_user('admin', '') #login admin
def checkReviewerRole(self): """ Checks if the 'Reviewer' role exists, creates and adds review permissions if it doesn't exist """ auth_tool = self.getAuthenticationTool() roles = auth_tool.list_all_roles() PERMISSION_GROUP = 'Review content' if 'Reviewer' not in roles: auth_tool.addRole('Reviewer', [PERMISSION_REVIEW_SIMPLECONSULTATION]) else: permission_add_role(self, PERMISSION_REVIEW_SIMPLECONSULTATION, 'Reviewer') #give permissions to administrators admin_permissions = self.permissionsOfRole('Administrator') site = self.getSite() if PERMISSION_MANAGE_SIMPLECONSULTATION not in admin_permissions: site.manage_permission(PERMISSION_MANAGE_SIMPLECONSULTATION, ('Administrator', ), acquire=1) site.manage_permission(PERMISSION_REVIEW_SIMPLECONSULTATION, ('Administrator', ), acquire=1)
def _update(self, portal): permissions = [ "View", "Naaya - Copy content", "Naaya - Delete content", "Naaya - Edit content", "Add/Edit/Delete Naaya Forum Topic", "Edit/Delete Forum Message", "Add Naaya Forum Message", "Naaya - Add Naaya Event objects", "Naaya - Add Naaya Blob File objects", "Naaya - Add Naaya Folder objects", "Naaya - Add Naaya Document objects", "Naaya - Add Naaya Meeting objects", "Naaya - Add Naaya Media File objects", "Naaya - Add Naaya News objects", "Naaya - Add Naaya Photo", "Naaya - Add Naaya Pointer objects", "Naaya - Add Naaya URL objects", ] for p in permissions: permission_add_role(portal, p, 'Owner') self.log.debug('Done') return True