Exemple #1
0
 def handle_delete(self):
     data, errors = self.extractData()
     del self.context.__parent__[self.context.__name__]
     role_manager = IPrincipalRoleManager(grok.getSite())
     for role_id, setting in role_manager.getRolesForPrincipal(data['login']):
         role_manager.removeRoleFromPrincipal(role_id, data['login'])
     self.redirect(self.url(grok.getSite(), '/benutzer'))
Exemple #2
0
 def update(self, **data):
     cn = '%s-%s' % (self.mnr, data.get('az'))
     self.um.updUser(**data)
     for role in self.__parent__.values():
         principal_roles = IPrincipalRoleManager(role)
         principal_roles.removeRoleFromPrincipal('uvc.Editor', cn)
     for role in data.get('rollen'):
         principal_roles = IPrincipalRoleManager(self.__parent__[role])
         principal_roles.assignRoleToPrincipal('uvc.Editor', cn)
Exemple #3
0
 def update(self, **data):
     cn = '%s-%s' % (self.mnr, data.get('az'))
     self.um.updUser(**data)
     for role in self.__parent__.values():
         principal_roles = IPrincipalRoleManager(role)
         principal_roles.removeRoleFromPrincipal('uvc.Editor', cn)
     for role in data.get('rollen'):
         principal_roles = IPrincipalRoleManager(self.__parent__[role])
         principal_roles.assignRoleToPrincipal('uvc.Editor', cn)
Exemple #4
0
 def handle_add(self):
     data, errors = self.extractData()
     if errors:
         self.flash(u'Es ist ein Fehler aufgetreten', 'warning')
         return
     changes = apply_data_event(self.fields, self.context, data)
     role_manager = IPrincipalRoleManager(grok.getSite())
     for role_id, setting in role_manager.getRolesForPrincipal(data['login']):
         role_manager.removeRoleFromPrincipal(role_id, data['login'])
     role_manager.assignRoleToPrincipal(data['role'], data['login'])
     print role_manager.getRolesForPrincipal(data['login'])
     self.redirect(self.url(grok.getSite(), '/benutzer'))
    def roles(self, value):
        principal_id = self.__principal__.id
        rolemanager = IPrincipalRoleManager(getSite())

        for role, setting in value.items():
            if role not in self._roles:
                continue

            if setting is Allow:
                rolemanager.assignRoleToPrincipal(role, principal_id)
            elif setting is Deny:
                rolemanager.removeRoleFromPrincipal(role, principal_id)
            else:
                rolemanager.unsetRoleForPrincipal(role, principal_id)
Exemple #6
0
 def removeUser(self, username):
     user_folder = grok.getSite()['users']
     if username in user_folder:
         role_manager = IPrincipalRoleManager(grok.getSite())
         role_manager.removeRoleFromPrincipal('merlot.Manager', username)
         del user_folder[username]
Exemple #7
0
 def deny_role(self, role_id, pids):
     if isinstance(pids, basestring): pids = [pids]
     role_id = ROLE_MAP[role_id]
     prinrole = IPrincipalRoleManager(self.context)
     for pid in pids:
         prinrole.removeRoleFromPrincipal(role_id, pid)
Exemple #8
0
 def borrarUsuario(self, usuario):
     if usuario in self.contenedor_cuentas:
         role_manager = IPrincipalRoleManager(grok.getSite())
         rol = role_manager.getRolesForPrincipal(usuario)[0]
         role_manager.removeRoleFromPrincipal(rol[0], usuario)
         del self.contenedor_cuentas[usuario]
Exemple #9
0
 def borrarUsuario(self, usuario):
     if usuario in self.contenedor_cuentas:
         role_manager = IPrincipalRoleManager(grok.getSite())
         rol = role_manager.getRolesForPrincipal(usuario)[0]
         role_manager.removeRoleFromPrincipal(rol[0], usuario)
         del self.contenedor_cuentas[usuario]
Exemple #10
0
 def deny_role(self, role_id, pids):
     if isinstance(pids, basestring): pids = [pids]
     role_id = ROLE_MAP[role_id]
     prinrole = IPrincipalRoleManager(self.context)
     for pid in pids:
         prinrole.removeRoleFromPrincipal(role_id, pid)
    def status(self):
        setUpWidget(self, 'principal', self.principal_field, IInputWidget)
        if not self.principal_widget.hasInput():
            return u''
        try:
            principal = self.principal_widget.getInputValue()
        except MissingInputError:
            return u''

        self.principal = principal

        # Make sure we can use the principal id in a form by base64ing it
        principal_token = unicode(principal).encode('base64').strip().replace(
            '=', '_')

        roles = [role for name, role in getUtilitiesFor(IRole)]
        roles.sort(lambda x, y: cmp(x.title, y.title))
        principal_roles = IPrincipalRoleManager(self.context)

        self.roles = []
        for role in roles:
            name = principal_token + '.role.'+role.id
            field = zope.schema.Choice(__name__= name,
                                       title=role.title,
                                       vocabulary=settings_vocabulary)
            setUpWidget(self, name, field, IInputWidget,
                        principal_roles.getSetting(role.id, principal))
            self.roles.append(getattr(self, name+'_widget'))

        perms = [perm for name, perm in getUtilitiesFor(IPermission)]
        perms.sort(lambda x, y: cmp(x.title, y.title))
        principal_perms = IPrincipalPermissionManager(self.context)

        self.permissions = []
        for perm in perms:
            if perm.id == 'zope.Public':
                continue
            name = principal_token + '.permission.'+perm.id
            field = zope.schema.Choice(__name__=name,
                                       title=perm.title,
                                       vocabulary=settings_vocabulary)
            setUpWidget(self, name, field, IInputWidget,
                        principal_perms.getSetting(perm.id, principal))
            self.permissions.append(
                getattr(self, name+'_widget'))

        if 'GRANT_SUBMIT' not in self.request:
            return u''

        for role in roles:
            name = principal_token + '.role.'+role.id
            role_widget = getattr(self, name+'_widget')
            if role_widget.hasInput():
                try:
                    setting = role_widget.getInputValue()
                except MissingInputError:
                    pass
                else:
                    # Arrgh!
                    if setting is Allow:
                        principal_roles.assignRoleToPrincipal(
                            role.id, principal)
                    elif setting is Deny:
                        principal_roles.removeRoleFromPrincipal(
                            role.id, principal)
                    else:
                        principal_roles.unsetRoleForPrincipal(
                            role.id, principal)

        for perm in perms:
            if perm.id == 'zope.Public':
                continue
            name = principal_token + '.permission.'+perm.id
            perm_widget = getattr(self, name+'_widget')
            if perm_widget.hasInput():
                try:
                    setting = perm_widget.getInputValue()
                except MissingInputError:
                    pass
                else:
                    # Arrgh!
                    if setting is Allow:
                        principal_perms.grantPermissionToPrincipal(
                            perm.id, principal)
                    elif setting is Deny:
                        principal_perms.denyPermissionToPrincipal(
                            perm.id, principal)
                    else:
                        principal_perms.unsetPermissionForPrincipal(
                            perm.id, principal)

        return _('Grants updated.')
Exemple #12
0
 def delete(self, az):
     cn = '%s-%s' % (self.mnr, az)
     self.um.deleteUser(cn)
     for role in self.__parent__.values():
         principal_roles = IPrincipalRoleManager(role)
         principal_roles.removeRoleFromPrincipal('uvc.Editor', cn)
Exemple #13
0
 def delete(self, az):
     cn = '%s-%s' % (self.mnr, az)
     self.um.deleteUser(cn)
     for role in self.__parent__.values():
         principal_roles = IPrincipalRoleManager(role)
         principal_roles.removeRoleFromPrincipal('uvc.Editor', cn)