def GetAllRoles(self): ''' Get all the roles objects in the database server ''' rl = Role() qo = rl.queryObject() return qo.all()
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
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
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)
def DeleteSTDMRole(self,rolename): ''' Delete STDM role ''' rl = Role() existRole = rl.queryObject().filter(Role.name == rolename).first() if existRole != None: existRole.delete()
def DeleteSTDMRole(self, rolename): ''' Delete STDM role ''' rl = Role() existRole = rl.queryObject().filter(Role.name == rolename).first() if existRole != None: existRole.delete()
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()
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)
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()
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()
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()
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()