def test_role_roles(self): import ptah role = ptah.Role('myrole', 'MyRole') self.init_ptah() self.assertTrue('myrole' in ptah.get_roles()) self.assertTrue(ptah.get_roles()['myrole'] is role)
def test_role_defaults(self): roles = sorted(list(ptah.get_roles().keys()))[:3] self.assertTrue(['Authenticated', 'Everyone', 'Owner'] == roles) self.assertTrue(ptah.get_roles()['Everyone'].id == 'system.Everyone') self.assertTrue( ptah.get_roles()['Authenticated'].id == 'system.Authenticated') self.assertTrue(ptah.get_roles()['Owner'].id == 'system.Owner')
def test_role_roles(self): import ptah role = ptah.Role("myrole", "MyRole") self._init_ptah() self.assertTrue("myrole" in ptah.get_roles()) self.assertTrue(ptah.get_roles()["myrole"] is role)
def test_role_defaults(self): import ptah roles = sorted(list(ptah.get_roles().keys()))[:3] self.assertTrue(['Authenticated', 'Everyone', 'Owner'] == roles) self.assertTrue(ptah.get_roles()['Everyone'].id == 'system.Everyone') self.assertTrue(ptah.get_roles()['Authenticated'].id=='system.Authenticated') self.assertTrue(ptah.get_roles()['Owner'].id=='system.Owner')
def test_role_defaults(self): import ptah self._init_ptah() roles = list(ptah.get_roles().keys()) roles.sort() roles = roles[:3] self.assertTrue(["Authenticated", "Everyone", "Owner"] == roles) self.assertTrue(ptah.get_roles()["Everyone"].id == "system.Everyone") self.assertTrue(ptah.get_roles()["Authenticated"].id == "system.Authenticated") self.assertTrue(ptah.get_roles()["Owner"].id == "system.Owner")
def update(self): res = super(SharingForm, self).update() request = self.request context = self.context self.roles = [r for r in ptah.get_roles().values() if not r.system] self.local_roles = local_roles = context.__local_roles__ term = request.session.get('apps-sharing-term', '') if term: self.users = list(ptah.search_principals(term)) if 'form.buttons.save' in request.POST: users = [] userdata = {} for attr, val in request.POST.items(): if attr.startswith('user-'): userId, roleId = attr[5:].rsplit('-',1) data = userdata.setdefault(str(userId), []) data.append(str(roleId)) if attr.startswith('userid-'): users.append(str(attr.split('userid-')[-1])) for uid in users: if userdata.get(uid): local_roles[str(uid)] = userdata[uid] elif uid in local_roles: del local_roles[uid] context.__local_roles__ = local_roles return res
def update(self): super(SharingForm, self).update() request = self.request context = self.context self.roles = [r for r in ptah.get_roles().values() if not r.system] self.local_roles = local_roles = context.__local_roles__ term = request.session.get('sharing-search-term', '') if term: self.users = list(ptah.search_principals(term)) if 'form.buttons.save' in request.POST: users = [] userdata = {} for attr, val in request.POST.items(): if attr.startswith('user-'): userId, roleId = attr[5:].rsplit('-', 1) data = userdata.setdefault(str(userId), []) data.append(str(roleId)) if attr.startswith('userid-'): users.append(str(attr.split('userid-')[-1])) for uid in users: if userdata.get(uid): local_roles[str(uid)] = userdata[uid] elif uid in local_roles: del local_roles[uid] context.__local_roles__ = local_roles
def get_roles_vocabulary(context): roles = [] for name, role in ptah.get_roles().items(): if role.system: continue roles.append([role.title, form.SimpleTerm(role.id, role.id, role.title)]) return form.SimpleVocabulary(*[term for _t, term in sorted(roles)])
def get_roles_vocabulary(context): roles = [] for name, role in ptah.get_roles().items(): if role.system: continue roles.append( [role.title, ptah.form.Term(role.id, role.id, role.title)]) return ptah.form.Vocabulary(*[term for _t, term in sorted(roles)])
def __init__(self, context, request): self.tinfo = context.__type__ self.roles = [r for r in ptah.get_roles().values() if not r.system] self.local_roles = local_roles = context.__local_roles__ self.local_principals = [ptah.resolve(principalUri) for principalUri in self.local_roles] for p in list(ptah.search_principals('')): p = ptah.resolve(p.__uri__) if hasattr(p, 'properties'): if p.properties.get('roles') and p not in self.local_principals: self.local_principals.append(p) self.principals = sorted(self.local_principals, key=lambda p: str(p)) super(ShareForm, self).__init__(context, request)
def __init__(self, context, request): self.tinfo = context.__type__ self.roles = [r for r in ptah.get_roles().values() if not r.system] self.local_roles = local_roles = context.__local_roles__ self.local_principals = [ ptah.resolve(principalUri) for principalUri in self.local_roles ] for p in list(ptah.search_principals('')): p = ptah.resolve(p.__uri__) if hasattr(p, 'properties'): if p.properties.get( 'roles') and p not in self.local_principals: self.local_principals.append(p) self.principals = sorted(self.local_principals, key=lambda p: str(p)) super(ShareForm, self).__init__(context, request)
def update(self): self.roles = sorted(ptah.get_roles().values(), key=lambda r: r.title)
def update(self): self.roles = ptah.get_roles().values() self.roles.sort(key = lambda r: r.title)
def renderActions(self, *actions): return self.actions( roles = ptah.get_roles(), actions = actions, manage_url = manage.CONFIG.manage_url, request = self.request)
def renderActions(self, *actions): return self.actions( roles = ptah.get_roles(), actions = actions, request = self.request)