def permissions_for_user(cls, user, config): if user is None: user = User() user.display_name = u'Anonymous User' user.user_name = u'anonymous' user.email_address = '*****@*****.**' anonymous_group = Group.by_name(u'anonymous') groups = filter(None, [anonymous_group]) else: meta_groups = Group.query.filter(Group.group_name.in_([u'anonymous', u'authenticated'])) groups = list(user.groups) + list(meta_groups) return UserPermissions(user, cls(config), groups=groups)
def setUp(self): super(FilteringRestrictedItemsTest, self).setUp() # without explicit re-registration of the default policy unit tests # failed when running 'python setup.py test' self._register_default_policy() # get rid of default media Media.query.delete() self.private_media = Media.example(slug=u'private') self.public_media = Media.example(slug=u'public') self.permission_system = MediaCorePermissionSystem(self.pylons_config) self.media_query = Media.query user = self._create_user_without_groups() self.perm = UserPermissions(user, self.permission_system)
def setUp(self): self.system = PermissionSystem([]) user = AttrDict(groups=[]) self.perm = UserPermissions(user, self.system)
def perm(self): system = MediaCorePermissionSystem(self.pylons_config) system.policies = [self.policy] user = DBSession.query(User).filter(User.user_name == u'admin').one() return UserPermissions(user, system)