-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #173 from raphaelrpl/b-1.0
Add minimal role support for collections management
- Loading branch information
Showing
11 changed files
with
160 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
"""add minimal roles system | ||
Revision ID: 5067fb4381c0 | ||
Revises: d01f09b5dd8b | ||
Create Date: 2022-08-15 09:01:16.510820 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy.dialects import postgresql | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '5067fb4381c0' | ||
down_revision = 'd01f09b5dd8b' | ||
branch_labels = () | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_column('items', 'is_public', schema='bdc') | ||
|
||
op.create_table( | ||
'roles', | ||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), | ||
sa.Column('name', sa.String(length=64), nullable=False), | ||
sa.Column('description', sa.Text(), nullable=True), | ||
sa.Column('created', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False), | ||
sa.Column('updated', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False), | ||
sa.PrimaryKeyConstraint('id', name=op.f('roles_pkey')), | ||
sa.UniqueConstraint('name', name=op.f('roles_name_key')), | ||
schema='bdc' | ||
) | ||
op.create_index(op.f('idx_bdc_roles_name'), 'roles', ['name'], unique=False, schema='bdc') | ||
op.create_table( | ||
'collections_roles', | ||
sa.Column('collection_id', sa.Integer(), nullable=False), | ||
sa.Column('role_id', sa.Integer(), nullable=False), | ||
sa.Column('created', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False), | ||
sa.Column('updated', sa.TIMESTAMP(timezone=True), server_default=sa.text('now()'), nullable=False), | ||
sa.ForeignKeyConstraint(['collection_id'], ['bdc.collections.id'], name=op.f('collections_roles_collection_id_collections_fkey'), onupdate='CASCADE', ondelete='CASCADE'), | ||
sa.ForeignKeyConstraint(['role_id'], ['bdc.roles.id'], name=op.f('collections_roles_role_id_roles_fkey'), onupdate='CASCADE', ondelete='CASCADE'), | ||
sa.PrimaryKeyConstraint('collection_id', 'role_id', name=op.f('collections_roles_pkey')), | ||
schema='bdc' | ||
) | ||
|
||
op.drop_constraint('collections_classification_system_id_class_systems_fkey', 'collections', schema='bdc', type_='foreignkey') | ||
op.create_foreign_key(op.f('collections_classification_system_id_classification_systems_fkey'), 'collections', 'classification_systems', ['classification_system_id'], ['id'], source_schema='bdc', referent_schema='lccs', onupdate='CASCADE', ondelete='CASCADE') | ||
op.drop_column('collections', 'is_public', schema='bdc') | ||
|
||
op.create_index(op.f('idx_bdc_quicklook_collection_id'), 'quicklook', ['collection_id'], unique=False, schema='bdc') | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_index(op.f('idx_bdc_quicklook_collection_id'), table_name='quicklook', schema='bdc') | ||
|
||
op.drop_constraint(op.f('collections_classification_system_id_classification_systems_fkey'), 'collections', schema='bdc', type_='foreignkey') | ||
op.create_foreign_key('collections_classification_system_id_class_systems_fkey', 'collections', 'classification_systems', ['classification_system_id'], ['id'], source_schema='bdc', referent_schema='lccs') | ||
|
||
op.drop_table('collections_roles', schema='bdc') | ||
op.drop_index(op.f('idx_bdc_roles_name'), table_name='roles', schema='bdc') | ||
op.drop_table('roles', schema='bdc') | ||
|
||
op.add_column('items', sa.Column('is_public', sa.Boolean, nullable=True, default=True, server_default='true'), | ||
schema='bdc') | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# | ||
# This file is part of Brazil Data Cube Database module. | ||
# Copyright (C) 2022 INPE. | ||
# | ||
# Brazil Data Cube Database module is free software; you can redistribute it and/or modify it | ||
# under the terms of the MIT License; see LICENSE file for more details. | ||
# | ||
|
||
"""Model for table ``bdc.role``.""" | ||
|
||
from sqlalchemy import Column, Index, Integer, String, Text | ||
from sqlalchemy.orm import relationship | ||
|
||
from ..config import BDC_CATALOG_SCHEMA | ||
from .base_sql import BaseModel | ||
|
||
|
||
class Role(BaseModel): | ||
"""Model for table ``bdc.role``. | ||
The role model consists in a basic way to specify a required roles to access collections/items. | ||
These values are used by BDC-Catalog NGINX plugin in order to validate user access. | ||
""" | ||
|
||
__tablename__ = 'roles' | ||
|
||
id = Column(Integer, primary_key=True, autoincrement=True) | ||
name = Column(String(64), unique=True, nullable=False) | ||
description = Column(Text) | ||
|
||
__table_args__ = ( | ||
Index(None, name), | ||
dict(schema=BDC_CATALOG_SCHEMA), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ | |
"""Version information for BDC-Catalog.""" | ||
|
||
|
||
__version__ = '1.0.0-alpha2' | ||
__version__ = '1.0.0-alpha3' |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.