示例#1
0
 def GetAllRoles(self):
     '''
     Get all the roles objects in the database server
     '''
     rl = Role()
     qo = rl.queryObject()
     return qo.all()
示例#2
0
 def GetRole(self, rolename):
     '''
     Get the STDM role object based on the rolename
     '''
     rl = Role()
     role = rl.queryObject().filter(Role.name == rolename).first()
     return role
示例#3
0
 def GetRole(self,rolename):
     '''
     Get the STDM role object based on the rolename
     '''
     rl = Role()
     role = rl.queryObject().filter(Role.name == rolename).first()
     return role
示例#4
0
 def GetAllRoles(self):
     '''
     Get all the roles objects in the database server
     '''
     rl = Role()
     qo = rl.queryObject()
     return qo.all()
示例#5
0
 def onRoleSelected(self,index):
     '''
     Slot which is called when a user checks/unchecks to add/remove a role for the 
     specified content item.
     '''
     if self.currentContent != None:
         
         item = self.roleMappingsModel.itemFromIndex(index)
         rolename = item.text()
         
         #Get role object from role name
         role = Role()
         rl = role.queryObject().filter(Role.name == rolename).first()
         
         self.blockSignals(True)            
         
         #Add role to the content item if the item is selected  or remove if it was previosuly checked
         if item.checkState() == Qt.Checked:    
             self.currentContent.roles.append(rl)             
             
         elif item.checkState() == Qt.Unchecked:
             self.currentContent.roles.remove(rl)
             
         self.currentContent.update()
             
         self.blockSignals(False)
示例#6
0
 def DeleteSTDMRole(self,rolename):
     '''
     Delete STDM role
     '''
     rl = Role()
     existRole = rl.queryObject().filter(Role.name == rolename).first()
     if existRole != None:
         existRole.delete()            
示例#7
0
 def DeleteSTDMRole(self, rolename):
     '''
     Delete STDM role
     '''
     rl = Role()
     existRole = rl.queryObject().filter(Role.name == rolename).first()
     if existRole != None:
         existRole.delete()
示例#8
0
    def register(self):
        """
        Registers the content items into the database. Registration only works for a 
        postgres user account.
        """
        pg_account = "postgres"

        if self._username == pg_account:
            for c in self.contentItems():
                if isinstance(c, Content):
                    cnt = Content()
                    qo = cnt.queryObject()
                    cn = qo.filter(Content.code == c.code).first()

                    #If content not found then add
                    if cn == None:
                        #Check if the 'postgres' role is defined, if not then create one
                        rl = Role()
                        rolequery = rl.queryObject()
                        role = rolequery.filter(
                            Role.name == pg_account).first()

                        if role == None:
                            rl.name = pg_account
                            rl.contents = [c]
                            rl.save()
                        else:
                            existingContents = role.contents
                            #Append new content to existing
                            existingContents.append(c)
                            role.contents = existingContents
                            role.update()

            #Initialize lookup values
            initLookups()
示例#9
0
    def _setRole(self):
        '''
        Create/update the user object based on the user input
        '''
        roleName = self.txtRoleName.text()
        roleDescription = self.txtRoleDescription.text()

        if self.role == None:
            self.role = Role()
            self.role.name = roleName
            self.role.description = string.strip(roleDescription)
示例#10
0
 def AddSTDMRole(self, rolename, description=""):
     '''
     Add role to STDM roles table
     '''
     rl = Role()
     existRole = rl.queryObject().filter(Role.name == rolename).first()
     if existRole == None:
         rl.name = rolename
         rl.description = description
         rl.save()
示例#11
0
    def register(self):
        """
        Registers the content items into the database. Registration only works for a
        postgres user account.
        """
        pg_account = "docker"

        if self._username == pg_account:
            for c in self.contentItems():
                if isinstance(c,Content):
                    cnt = Content()
                    qo = cnt.queryObject()
                    cn = qo.filter(Content.code == c.code).first()

                    #If content not found then add
                    if cn == None:
                        #Check if the 'postgres' role is defined, if not then create one
                        rl = Role()
                        rolequery = rl.queryObject()
                        role = rolequery.filter(Role.name == pg_account).first()

                        if role == None:
                            rl.name = pg_account
                            rl.contents = [c]
                            rl.save()
                        else:
                            existingContents = role.contents
                            #Append new content to existing
                            existingContents.append(c)
                            role.contents = existingContents
                            role.update()

            #Initialize lookup values
            initLookups()
示例#12
0
 def register(self):
     """
     Registers the content items into the database. Registration only works for a 
     postgres user account.
     """
     pg_account = "postgres"   
     
     if self._username == pg_account:
         for c in self.contentItems():
             if isinstance(c,Content):
                 cnt = Content()
                 #self.content=Table('content_base',Base.metadata,autoload=True,autoload_with=STDMDb.instance().engine)
                 qo = cnt.queryObject()
                 cn = qo.filter(Content.code == c.code).first()
                 
                 #If content not found then add
                 if cn == None:                            
                     #Check if the 'postgres' role is defined, if not then create one
                     rl = Role()
                     rolequery = rl.queryObject()
                     role = rolequery.filter(Role.name == pg_account).first()
                     
                     if role == None:
                         rl.name = pg_account
                         rl.contents = [c]
                         rl.save()                     
                     else:
                         existingContents = role.contents
                         #Append new content to existing 
                         existingContents.append(c)
                         role.contents = existingContents
                         role.update()     
示例#13
0
 def AddSTDMRole(self,rolename,description = ""):
     '''
     Add role to STDM roles table
     '''
     rl = Role()
     existRole = rl.queryObject().filter(Role.name == rolename).first()        
     if existRole == None:
         rl.name = rolename 
         rl.description = description   
         rl.save()