Example #1
0
 def createInProductFolder(self):
     homefolder = IHomeFolder(self.principal).homeFolder
     if not homefolder:
         utility = getUtility(IHomeFolderManager)
         utility.assignHomeFolder(uvcsite.IMasterUser(self.principal).id)
     if self.folderURI and not self.folderURI in homefolder.keys():
         pf = self.productfolder
         homefolder[self.folderURI] = pf()
         uvcsite.log('Add Productfolders %s to Homefolder: %s' %
                     (self.folderURI, self.principal.id),
                     severity=logging.DEBUG)
Example #2
0
 def test_auth_event(self):
     class F:
         def __init__(self, p):
             self.object = p
     self.layer.create_application('app')
     principal = Principal('0101010001')
     homefolder = IHomeFolder(principal, None)
     self.assertEqual(homefolder, None)
     from uvcsite.auth.event import applyPermissionsForExistentCoUsers
     applyPermissionsForExistentCoUsers(F(principal))
     homefolder = IHomeFolder(principal)
     from uvcsite.homefolder.homefolder import HomeFolder
     self.assertTrue(isinstance(homefolder, HomeFolder))
     self.assertEqual(str(homefolder), '<Homefolder for 0101010001>')
Example #3
0
 def getURL(self, type=""):
     principal = self.request.principal
     if IUnauthenticatedPrincipal.providedBy(principal):
         return
     homeFolder = IHomeFolder(principal).homeFolder
     homeFolder = grok.url(self.request, homeFolder, type)
     return homeFolder
Example #4
0
class MyRoles(grok.Adapter):
    grok.context(IPrincipal)

    def __init__(self, principal):
        self.principal = principal
        self.homefolder = IHomeFolder(IMasterUser(self.principal))

    def getAllRoles(self):
        ret = []
        hfr = IPrincipalRoleMap(self.homefolder, None)
        if hfr is None:
            return ret

        masteruser = False
        for rolesetting in hfr.getRolesForPrincipal(self.principal.id):
            role, setting = rolesetting
            if 'uvc.Editor' == role and setting is Allow:
                masteruser = True
                ret.append('ENMS')
        for name, productfolder in self.homefolder.items():
            if not name.startswith('__'):
                if masteruser:
                    ret.append(name)
                else:
                    prm = IPrincipalRoleMap(productfolder)
                    for rolesetting in prm.getRolesForPrincipal(
                            self.principal.id):
                        role, setting = rolesetting
                        if 'uvc.Editor' == role and setting is Allow:
                            ret.append(name)
        return ret
Example #5
0
 def update(self):
     """ Wir müssen zunächst eine Instanz der Unfallanzeige
         anlegen. Diese Instanz dient als Context für den
         Wizard.
     """
     hf = IHomeFolder(self.request.principal).homeFolder
     self.uaz = uaz = Unfallanzeige()
     hf['Unfallanzeigen'].add(uaz)
Example #6
0
 def url(self):
     principal = self.request.principal
     if IUnauthenticatedPrincipal.providedBy(principal):
         return
     hf = IHomeFolder(principal, None)
     if hf:
         return urllib.parse.unquote(grok.util.url(self.request, hf))
     return ""
Example #7
0
 def url(self):
     principal = self.request.principal
     if IUnauthenticatedPrincipal.providedBy(principal):
         return
     homeFolder = IHomeFolder(principal, None)
     if homeFolder:
         return str(absoluteURL(homeFolder, self.request)) + "/enms"
     return ""
Example #8
0
 def url(self):
     principal = self.request.principal
     if IUnauthenticatedPrincipal.providedBy(principal):
         return
     hf = IHomeFolder(principal, None)
     if None:
         return ""
     viewname = "personalpanelview"
     return urllib.parse.unquote(grok.util.url(self.request, hf, viewname))
Example #9
0
def applyViewContentForCoUsers(factory):
    principal = factory.object
    homefolder = IHomeFolder(principal).homeFolder
    if not homefolder:
        return
    if homefolder.__name__ != principal.id:
        hprm = IPrincipalRoleManager(homefolder)
        setting = hprm.getSetting('uvc.HomeFolderUser', principal.id).getName()
        if setting in ('Deny', 'Unset'):
            hprm.assignRoleToPrincipal('uvc.HomeFolderUser', principal.id)
            log('applying Role uvc.HomeFolderUser for USER %s in HOMEFOLDER %s'
                % (principal.id, homefolder.__name__))
Example #10
0
def applyPermissionsForExistentCoUsers(factory):
    return
    principal = factory.object
    createProductFolders(principal)
    homefolder = IHomeFolder(principal).homeFolder
    if not homefolder:
        return
    um = getUtility(IUserManagement)
    user = um.getUser(principal.id)
    if not user:
        return
    rollen = user['rollen']
    if user['az'] != '00':
        pid = "%s-%s" % (user['mnr'], user['az'])
    else:
        pid = user['mnr']
    if homefolder.__name__ != pid:
        for pf in homefolder.keys():
            if pf in rollen:
                prm = IPrincipalRoleManager(homefolder.get(pf))
                if prm.getSetting('uvc.Editor', pid).getName() == 'Unset':
                    prm.assignRoleToPrincipal('uvc.Editor', pid)
                    uvcsite.log('Give uvc.Editor to %s in folder %s' %
                                (pid, pf))
Example #11
0
 def anlegen(self):
     data, errors = self.extractData()
     if errors:
         self.flash('Es sind Fehler aufgetreten', type='error')
         return
     um = getUtility(IUserManagement)
     um.addUser(**data)
     # Setting Home Folder Rights
     for role in data.get('rollen'):
         principal_roles = IPrincipalRoleManager(
             self.context.__parent__[role])
         principal_roles.assignRoleToPrincipal('uvc.Editor',
                                               data.get('mnr'))
     self.flash(_('Der Mitbenutzer wurde gespeichert'))
     principal = self.request.principal
     homeFolder = IHomeFolder(principal)
     self.redirect(self.url(homeFolder, '++enms++'))
Example #12
0
 def action(self):
     return self.view.url(
         IHomeFolder(self.request.principal).homeFolder, 'changepassword')
Example #13
0
 def test_homefolder_instance(self):
     self.assert_(
         isinstance(IHomeFolder(self.user),
                    uvcsite.homefolder.homefolder.HomeFolderForPrincipal))
Example #14
0
 def url(self):
     return self.view.url(IHomeFolder(self.request.principal),
                          'changepassword')
Example #15
0
def getHomeFolder(request):
    principal = request.principal
    if IUnauthenticatedPrincipal.providedBy(principal):
        return
    return IHomeFolder(principal).homeFolder
Example #16
0
 def homefolder(self):
     return IHomeFolder(self).homeFolder
Example #17
0
 def __init__(self, principal):
     self.principal = principal
     self.homefolder = IHomeFolder(IMasterUser(self.principal))