def _global_rights(self): rights = AccessRights(inherit=False) if self._admin_role: rights.append( RoleAccess( self._admin_role.name, [AccessRight.VIEW, AccessRight.CHANGE, AccessRight.DELETE ])) return rights
def _user_table(): t = Table(accessRights=AccessRights(), name=NAMES['userTable']['name'], tableName='user', schema='system') t.columns.append( TableColumn(name=NAMES['userTable']['login'], rowName='login', isPk=True, isRequired=True, isUnique=True, type='varchar(256)', isEditable=False)) t.columns.append( LinkedTableColumn( name=NAMES['userTable']['roles'], rowName='roles', linkTableName='role', linkSchema='system', isMultiple=True, isRequired=False, linkRequired=False, linkMultiple=True, linkType=TableLinkType(TableLinkType.COMBINED), isUnique=False, )) t.buttonList = Buttons([ Button( text='Make registration token', location=Location.CARDHEADER, variant='outline-light', icon='["fas", "key"]', action=SystemAction.REGTOKEN, ), Button(location=Location.ACTION, icon='["fas", "unlock"]', action=SystemAction.PASSTOKEN, tooltip="Reset password") ]) return t
def _token_table(): t = Table(accessRights=AccessRights(), name=NAMES['tokenTable']['name'], tableName='token', schema='system') t.columns.append( TableColumn(name=NAMES['tokenTable']['token_name'], rowName='name', type='varchar(256)')) t.columns.append( TableColumn( rowName='token_hash', type='varchar(256)', isPk=True, isRequired=True, isEditable=False, isUnique=True, isVisible=False, )) t.columns.append( TableColumn(name=NAMES['tokenTable']['infinite'], rowName='infinite', isRequired=True, type='boolean')) t.columns.append( TableColumn(name=NAMES['tokenTable']['uses'], rowName='uses', isRequired=True, type='int4')) t.columns.append( TableColumn(name=NAMES['tokenTable']['time_limit'], rowName='time_limit', type='time_limit')) t.columns.append( TableColumn(name=NAMES['tokenTable']['description'], rowName='description', isRequired=True, type='json')) return t
def _make_table(self, table): t = Table(accessRights=AccessRights(), name=stringcase.sentencecase(table.name), tableName=table.name, schema=self._schema) for column in table.columns: t.columns.append(self._make_column(column)) local_fks = set([fk_col.name for fk_col in table.foreign_keys]) for relation in table.relationships: if relation.fk_col and relation.fk_col.name in local_fks: t.columns.append(self._make_linked_fk_column(relation)) if relation.fk_col.fk.column.pk: t.columns.append(self._make_hidden_pk_column(relation)) else: display_column = relation.display_column if display_column is not None: t.displayColumns.append( DisplayColumn(rowName=self._linked_name(relation), linkRowName=display_column.name, isMultiple=False)) else: t.columns.append(self._make_linked_nofk_column(relation)) display_column = relation.display_column if display_column is not None: t.displayColumns.append( DisplayColumn( rowName=self._linked_name(relation), linkRowName=display_column.name, isMultiple=relation.other_side.is_multiple)) t.formDescription = t.make_form() t.set_default_sort() if t.empty: t.hidden = True return t
def _add_elem(self, elem): elem.accessRights = AccessRights(inherit=False) self._mgr.h.append(elem) self._mgr.h.set_tree() self._update_tree()
def _sql(): sql = PrebuiltPage(accessRights=AccessRights(), name='SQL Console', type=PrebuiltPageType.SQL) return sql
def _parent_section(admin_role): rights = AccessRights(inherit=False) rights.append( RoleAccess(admin_role, [AccessRight.VIEW, AccessRight.CHANGE, AccessRight.DELETE])) return Section(accessRights=rights, name=NAMES['parentSection'])
def _roles_table(): t = Table(accessRights=AccessRights(), name=NAMES['rolesTable']['name'], tableName='role', schema='system') t.columns.append( TableColumn( name=NAMES['rolesTable']['role_name'], rowName='name', isPk=True, isRequired=True, isUnique=True, type='varchar(256)', )) t.columns.append( TableColumn( name=NAMES['rolesTable']['is_default'], rowName='is_default', isRequired=True, type='boolean', )) t.columns.append( TableColumn( name=NAMES['rolesTable']['can_reset_password'], rowName='can_reset_password', isRequired=True, type='boolean', )) t.columns.append( TableColumn( name=NAMES['rolesTable']['has_sql_access'], rowName='has_sql_access', isRequired=True, type='boolean', )) t.columns.append( TableColumn( name=NAMES['rolesTable']['can_register_all'], rowName='can_register_all', isRequired=True, type='boolean', )) t.columns.append( TableColumn( name=NAMES['rolesTable']['can_register'], rowName='can_register', type='array', )) t.columns.append( LinkedTableColumn( name=NAMES['rolesTable']['users'], rowName='users', linkTableName='user', linkSchema='system', isMultiple=True, isRequired=False, linkRequired=False, linkMultiple=True, linkType=TableLinkType(TableLinkType.COMBINED), isUnique=False, )) return t