Compare commits
6 Commits
main
...
feature/mo
| Author | SHA1 | Date | |
|---|---|---|---|
| 8e66161ddd | |||
| 588bff725b | |||
| 4fd66e0106 | |||
| 4512eb6e5c | |||
| 507f4db7fd | |||
| f8b6ab1739 |
0
.gitea/workflows/ci.yml
Normal file
0
.gitea/workflows/ci.yml
Normal file
0
ansible/deploy.yml
Normal file
0
ansible/deploy.yml
Normal file
0
ansible/inventory.ini
Normal file
0
ansible/inventory.ini
Normal file
0
ansible/secrets.yml
Normal file
0
ansible/secrets.yml
Normal file
4
makefile
4
makefile
@@ -6,6 +6,6 @@ VENV=source .venv/bin/activate;
|
|||||||
run:
|
run:
|
||||||
${VENV} python3 main.py
|
${VENV} python3 main.py
|
||||||
m_gen:
|
m_gen:
|
||||||
alembic revision --autogenerate
|
${VENV} alembic revision --autogenerate
|
||||||
m_up:
|
m_up:
|
||||||
alembic upgrade head
|
${VENV} alembic upgrade head
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
from logging.config import fileConfig
|
from logging.config import fileConfig
|
||||||
|
|
||||||
|
|
||||||
|
from src.models.database_models import Model
|
||||||
|
from src.models.database_models.model import engine
|
||||||
|
|
||||||
from sqlalchemy import engine_from_config
|
from sqlalchemy import engine_from_config
|
||||||
from sqlalchemy import pool
|
from sqlalchemy import pool
|
||||||
|
|
||||||
@@ -18,7 +22,8 @@ if config.config_file_name is not None:
|
|||||||
# for 'autogenerate' support
|
# for 'autogenerate' support
|
||||||
# from myapp import mymodel
|
# from myapp import mymodel
|
||||||
# target_metadata = mymodel.Base.metadata
|
# target_metadata = mymodel.Base.metadata
|
||||||
target_metadata = None
|
target_metadata = Model.metadata
|
||||||
|
config.set_main_option("sqlalchemy.url", engine.url.render_as_string(hide_password=False))
|
||||||
|
|
||||||
# other values from the config, defined by the needs of env.py,
|
# other values from the config, defined by the needs of env.py,
|
||||||
# can be acquired:
|
# can be acquired:
|
||||||
@@ -65,7 +70,7 @@ def run_migrations_online() -> None:
|
|||||||
|
|
||||||
with connectable.connect() as connection:
|
with connectable.connect() as connection:
|
||||||
context.configure(
|
context.configure(
|
||||||
connection=connection, target_metadata=target_metadata
|
connection=connection, target_metadata=target_metadata, render_as_batch=True
|
||||||
)
|
)
|
||||||
|
|
||||||
with context.begin_transaction():
|
with context.begin_transaction():
|
||||||
|
|||||||
69
src/migrations/versions/439a77f8a4d4_.py
Normal file
69
src/migrations/versions/439a77f8a4d4_.py
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
"""empty message
|
||||||
|
|
||||||
|
Revision ID: 439a77f8a4d4
|
||||||
|
Revises: 5e60c8fbc553
|
||||||
|
Create Date: 2026-07-22 15:19:15.853280
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = '439a77f8a4d4'
|
||||||
|
down_revision: Union[str, Sequence[str], None] = '5e60c8fbc553'
|
||||||
|
branch_labels: Union[str, Sequence[str], None] = None
|
||||||
|
depends_on: Union[str, Sequence[str], None] = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
"""Upgrade schema."""
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.create_table('markets',
|
||||||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('name', sa.String(length=64), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_markets')),
|
||||||
|
sa.UniqueConstraint('name', name=op.f('uq_markets_name'))
|
||||||
|
)
|
||||||
|
with op.batch_alter_table('markets', schema=None) as batch_op:
|
||||||
|
batch_op.create_index(batch_op.f('ix_markets_id'), ['id'], unique=False)
|
||||||
|
|
||||||
|
with op.batch_alter_table('reports', schema=None) as batch_op:
|
||||||
|
batch_op.add_column(sa.Column('doc_id', sa.Uuid(), nullable=False))
|
||||||
|
batch_op.add_column(sa.Column('uploaded_at', sa.TIMESTAMP(), nullable=False))
|
||||||
|
batch_op.add_column(sa.Column('doc_date', sa.TIMESTAMP(), nullable=False))
|
||||||
|
batch_op.add_column(sa.Column('status', sa.String(length=64), nullable=False))
|
||||||
|
batch_op.add_column(sa.Column('user_id', sa.Uuid(), nullable=False))
|
||||||
|
batch_op.add_column(sa.Column('market_id', sa.Integer(), nullable=False))
|
||||||
|
batch_op.create_index(batch_op.f('ix_reports_market_id'), ['market_id'], unique=False)
|
||||||
|
batch_op.create_index(batch_op.f('ix_reports_user_id'), ['user_id'], unique=False)
|
||||||
|
batch_op.create_unique_constraint(batch_op.f('uq_reports_doc_id'), ['doc_id'])
|
||||||
|
batch_op.create_foreign_key(batch_op.f('fk_reports_user_id_users'), 'users', ['user_id'], ['id'], ondelete='CASCADE')
|
||||||
|
batch_op.create_foreign_key(batch_op.f('fk_reports_market_id_markets'), 'markets', ['market_id'], ['id'], ondelete='CASCADE')
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
"""Downgrade schema."""
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
with op.batch_alter_table('reports', schema=None) as batch_op:
|
||||||
|
batch_op.drop_constraint(batch_op.f('fk_reports_market_id_markets'), type_='foreignkey')
|
||||||
|
batch_op.drop_constraint(batch_op.f('fk_reports_user_id_users'), type_='foreignkey')
|
||||||
|
batch_op.drop_constraint(batch_op.f('uq_reports_doc_id'), type_='unique')
|
||||||
|
batch_op.drop_index(batch_op.f('ix_reports_user_id'))
|
||||||
|
batch_op.drop_index(batch_op.f('ix_reports_market_id'))
|
||||||
|
batch_op.drop_column('market_id')
|
||||||
|
batch_op.drop_column('user_id')
|
||||||
|
batch_op.drop_column('status')
|
||||||
|
batch_op.drop_column('doc_date')
|
||||||
|
batch_op.drop_column('uploaded_at')
|
||||||
|
batch_op.drop_column('doc_id')
|
||||||
|
|
||||||
|
with op.batch_alter_table('markets', schema=None) as batch_op:
|
||||||
|
batch_op.drop_index(batch_op.f('ix_markets_id'))
|
||||||
|
|
||||||
|
op.drop_table('markets')
|
||||||
|
# ### end Alembic commands ###
|
||||||
143
src/migrations/versions/5e60c8fbc553_.py
Normal file
143
src/migrations/versions/5e60c8fbc553_.py
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
"""empty message
|
||||||
|
|
||||||
|
Revision ID: 5e60c8fbc553
|
||||||
|
Revises:
|
||||||
|
Create Date: 2026-07-17 20:02:01.237457
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy.sql import text
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = '5e60c8fbc553'
|
||||||
|
down_revision: Union[str, Sequence[str], None] = None
|
||||||
|
branch_labels: Union[str, Sequence[str], None] = None
|
||||||
|
depends_on: Union[str, Sequence[str], None] = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
"""Upgrade schema."""
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.create_table('groups_of_permissions',
|
||||||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('group', sa.String(length=255), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_groups_of_permissions')),
|
||||||
|
sa.UniqueConstraint('group', name=op.f('uq_groups_of_permissions_group'))
|
||||||
|
)
|
||||||
|
with op.batch_alter_table('groups_of_permissions', schema=None) as batch_op:
|
||||||
|
batch_op.create_index(batch_op.f('ix_groups_of_permissions_id'), ['id'], unique=False)
|
||||||
|
|
||||||
|
op.create_table('permissions',
|
||||||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('permission', sa.String(length=255), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_permissions')),
|
||||||
|
sa.UniqueConstraint('permission', name=op.f('uq_permissions_permission'))
|
||||||
|
)
|
||||||
|
with op.batch_alter_table('permissions', schema=None) as batch_op:
|
||||||
|
batch_op.create_index(batch_op.f('ix_permissions_id'), ['id'], unique=False)
|
||||||
|
op.execute(text("INSERT INTO permissions (permission) VALUES ('admin');"))
|
||||||
|
|
||||||
|
op.create_table('reports',
|
||||||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('filename', sa.String(length=255), nullable=False),
|
||||||
|
sa.Column('created_at', sa.TIMESTAMP(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_reports'))
|
||||||
|
)
|
||||||
|
with op.batch_alter_table('reports', schema=None) as batch_op:
|
||||||
|
batch_op.create_index(batch_op.f('ix_reports_filename'), ['filename'], unique=False)
|
||||||
|
batch_op.create_index(batch_op.f('ix_reports_id'), ['id'], unique=False)
|
||||||
|
|
||||||
|
op.create_table('users',
|
||||||
|
sa.Column('id', sa.Uuid(), nullable=False),
|
||||||
|
sa.Column('first_name', sa.String(length=64), nullable=False),
|
||||||
|
sa.Column('last_name', sa.String(length=64), nullable=False),
|
||||||
|
sa.Column('middle_name', sa.String(length=64), nullable=False),
|
||||||
|
sa.Column('email', sa.String(length=255), nullable=False),
|
||||||
|
sa.Column('status', sa.Boolean(), nullable=False),
|
||||||
|
sa.Column('hashed_password', sa.String(length=255), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_users'))
|
||||||
|
)
|
||||||
|
with op.batch_alter_table('users', schema=None) as batch_op:
|
||||||
|
batch_op.create_index(batch_op.f('ix_users_email'), ['email'], unique=True)
|
||||||
|
batch_op.create_index(batch_op.f('ix_users_first_name'), ['first_name'], unique=False)
|
||||||
|
batch_op.create_index(batch_op.f('ix_users_last_name'), ['last_name'], unique=False)
|
||||||
|
batch_op.create_index(batch_op.f('ix_users_middle_name'), ['middle_name'], unique=False)
|
||||||
|
|
||||||
|
op.create_table('group_permission',
|
||||||
|
sa.Column('group_id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('permission_id', sa.Integer(), nullable=False),
|
||||||
|
sa.ForeignKeyConstraint(['group_id'], ['groups_of_permissions.id'], name=op.f('fk_group_permission_group_id_groups_of_permissions')),
|
||||||
|
sa.ForeignKeyConstraint(['permission_id'], ['permissions.id'], name=op.f('fk_group_permission_permission_id_permissions')),
|
||||||
|
sa.PrimaryKeyConstraint('group_id', 'permission_id', name=op.f('pk_group_permission'))
|
||||||
|
)
|
||||||
|
op.create_table('refresh_tokens',
|
||||||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('user_id', sa.Uuid(), nullable=False),
|
||||||
|
sa.Column('token_hash', sa.String(length=255), nullable=False),
|
||||||
|
sa.Column('device_info', sa.String(length=255), nullable=False),
|
||||||
|
sa.Column('ip_address', sa.String(length=45), nullable=False),
|
||||||
|
sa.Column('is_revoked', sa.Boolean(), nullable=False),
|
||||||
|
sa.Column('expires_at', sa.TIMESTAMP(), nullable=False),
|
||||||
|
sa.Column('created_at', sa.TIMESTAMP(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False),
|
||||||
|
sa.Column('replaced_by', sa.Integer(), nullable=True),
|
||||||
|
sa.ForeignKeyConstraint(['replaced_by'], ['refresh_tokens.id'], name=op.f('fk_refresh_tokens_replaced_by_refresh_tokens')),
|
||||||
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], name=op.f('fk_refresh_tokens_user_id_users'), ondelete='CASCADE'),
|
||||||
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_refresh_tokens')),
|
||||||
|
sa.UniqueConstraint('token_hash', name=op.f('uq_refresh_tokens_token_hash'))
|
||||||
|
)
|
||||||
|
with op.batch_alter_table('refresh_tokens', schema=None) as batch_op:
|
||||||
|
batch_op.create_index(batch_op.f('ix_refresh_tokens_id'), ['id'], unique=False)
|
||||||
|
batch_op.create_index(batch_op.f('ix_refresh_tokens_user_id'), ['user_id'], unique=False)
|
||||||
|
|
||||||
|
op.create_table('user_direct_permissions',
|
||||||
|
sa.Column('user_id', sa.Uuid(), nullable=False),
|
||||||
|
sa.Column('permission_id', sa.Integer(), nullable=False),
|
||||||
|
sa.ForeignKeyConstraint(['permission_id'], ['permissions.id'], name=op.f('fk_user_direct_permissions_permission_id_permissions')),
|
||||||
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], name=op.f('fk_user_direct_permissions_user_id_users')),
|
||||||
|
sa.PrimaryKeyConstraint('user_id', 'permission_id', name=op.f('pk_user_direct_permissions'))
|
||||||
|
)
|
||||||
|
op.create_table('user_group',
|
||||||
|
sa.Column('user_id', sa.Uuid(), nullable=False),
|
||||||
|
sa.Column('permission_group_id', sa.Integer(), nullable=False),
|
||||||
|
sa.ForeignKeyConstraint(['permission_group_id'], ['groups_of_permissions.id'], name=op.f('fk_user_group_permission_group_id_groups_of_permissions')),
|
||||||
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], name=op.f('fk_user_group_user_id_users')),
|
||||||
|
sa.PrimaryKeyConstraint('user_id', 'permission_group_id', name=op.f('pk_user_group'))
|
||||||
|
)
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
"""Downgrade schema."""
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.drop_table('user_group')
|
||||||
|
op.drop_table('user_direct_permissions')
|
||||||
|
with op.batch_alter_table('refresh_tokens', schema=None) as batch_op:
|
||||||
|
batch_op.drop_index(batch_op.f('ix_refresh_tokens_user_id'))
|
||||||
|
batch_op.drop_index(batch_op.f('ix_refresh_tokens_id'))
|
||||||
|
|
||||||
|
op.drop_table('refresh_tokens')
|
||||||
|
op.drop_table('group_permission')
|
||||||
|
with op.batch_alter_table('users', schema=None) as batch_op:
|
||||||
|
batch_op.drop_index(batch_op.f('ix_users_middle_name'))
|
||||||
|
batch_op.drop_index(batch_op.f('ix_users_last_name'))
|
||||||
|
batch_op.drop_index(batch_op.f('ix_users_first_name'))
|
||||||
|
batch_op.drop_index(batch_op.f('ix_users_email'))
|
||||||
|
|
||||||
|
op.drop_table('users')
|
||||||
|
with op.batch_alter_table('reports', schema=None) as batch_op:
|
||||||
|
batch_op.drop_index(batch_op.f('ix_reports_id'))
|
||||||
|
batch_op.drop_index(batch_op.f('ix_reports_filename'))
|
||||||
|
|
||||||
|
op.drop_table('reports')
|
||||||
|
with op.batch_alter_table('permissions', schema=None) as batch_op:
|
||||||
|
batch_op.drop_index(batch_op.f('ix_permissions_id'))
|
||||||
|
|
||||||
|
op.drop_table('permissions')
|
||||||
|
with op.batch_alter_table('groups_of_permissions', schema=None) as batch_op:
|
||||||
|
batch_op.drop_index(batch_op.f('ix_groups_of_permissions_id'))
|
||||||
|
|
||||||
|
op.drop_table('groups_of_permissions')
|
||||||
|
# ### end Alembic commands ###
|
||||||
103
src/migrations/versions/75074097a2a3_.py
Normal file
103
src/migrations/versions/75074097a2a3_.py
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
"""empty message
|
||||||
|
|
||||||
|
Revision ID: 75074097a2a3
|
||||||
|
Revises: 8c300c4d43ea
|
||||||
|
Create Date: 2026-07-22 16:11:08.077455
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = '75074097a2a3'
|
||||||
|
down_revision: Union[str, Sequence[str], None] = '8c300c4d43ea'
|
||||||
|
branch_labels: Union[str, Sequence[str], None] = None
|
||||||
|
depends_on: Union[str, Sequence[str], None] = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
"""Upgrade schema."""
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.create_table('accountant_settings',
|
||||||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('name', sa.String(length=64), nullable=False),
|
||||||
|
sa.Column('database_key', sa.Uuid(), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_accountant_settings')),
|
||||||
|
sa.UniqueConstraint('database_key', name=op.f('uq_accountant_settings_database_key'))
|
||||||
|
)
|
||||||
|
with op.batch_alter_table('accountant_settings', schema=None) as batch_op:
|
||||||
|
batch_op.create_index(batch_op.f('ix_accountant_settings_id'), ['id'], unique=False)
|
||||||
|
batch_op.create_index(batch_op.f('ix_accountant_settings_name'), ['name'], unique=True)
|
||||||
|
|
||||||
|
op.create_table('doc_types',
|
||||||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('name', sa.String(length=64), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_doc_types'))
|
||||||
|
)
|
||||||
|
with op.batch_alter_table('doc_types', schema=None) as batch_op:
|
||||||
|
batch_op.create_index(batch_op.f('ix_doc_types_id'), ['id'], unique=False)
|
||||||
|
batch_op.create_index(batch_op.f('ix_doc_types_name'), ['name'], unique=True)
|
||||||
|
|
||||||
|
op.create_table('fabric',
|
||||||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('name', sa.String(length=64), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_fabric'))
|
||||||
|
)
|
||||||
|
with op.batch_alter_table('fabric', schema=None) as batch_op:
|
||||||
|
batch_op.create_index(batch_op.f('ix_fabric_id'), ['id'], unique=False)
|
||||||
|
batch_op.create_index(batch_op.f('ix_fabric_name'), ['name'], unique=True)
|
||||||
|
|
||||||
|
op.create_table('goods',
|
||||||
|
sa.Column('id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('article', sa.String(length=16), nullable=False),
|
||||||
|
sa.Column('price', sa.Numeric(precision=10, scale=2), nullable=False),
|
||||||
|
sa.Column('tnvd', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('doc_type_id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('fabric_id', sa.Integer(), nullable=False),
|
||||||
|
sa.Column('status', sa.Boolean(), nullable=False),
|
||||||
|
sa.ForeignKeyConstraint(['doc_type_id'], ['doc_types.id'], name=op.f('fk_goods_doc_type_id_doc_types'), ondelete='CASCADE'),
|
||||||
|
sa.ForeignKeyConstraint(['fabric_id'], ['fabric.id'], name=op.f('fk_goods_fabric_id_fabric'), ondelete='CASCADE'),
|
||||||
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_goods'))
|
||||||
|
)
|
||||||
|
with op.batch_alter_table('goods', schema=None) as batch_op:
|
||||||
|
batch_op.create_index(batch_op.f('ix_goods_article'), ['article'], unique=True)
|
||||||
|
batch_op.create_index(batch_op.f('ix_goods_doc_type_id'), ['doc_type_id'], unique=False)
|
||||||
|
batch_op.create_index(batch_op.f('ix_goods_fabric_id'), ['fabric_id'], unique=False)
|
||||||
|
batch_op.create_index(batch_op.f('ix_goods_id'), ['id'], unique=False)
|
||||||
|
batch_op.create_index(batch_op.f('ix_goods_price'), ['price'], unique=False)
|
||||||
|
batch_op.create_index(batch_op.f('ix_goods_tnvd'), ['tnvd'], unique=True)
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
"""Downgrade schema."""
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
with op.batch_alter_table('goods', schema=None) as batch_op:
|
||||||
|
batch_op.drop_index(batch_op.f('ix_goods_tnvd'))
|
||||||
|
batch_op.drop_index(batch_op.f('ix_goods_price'))
|
||||||
|
batch_op.drop_index(batch_op.f('ix_goods_id'))
|
||||||
|
batch_op.drop_index(batch_op.f('ix_goods_fabric_id'))
|
||||||
|
batch_op.drop_index(batch_op.f('ix_goods_doc_type_id'))
|
||||||
|
batch_op.drop_index(batch_op.f('ix_goods_article'))
|
||||||
|
|
||||||
|
op.drop_table('goods')
|
||||||
|
with op.batch_alter_table('fabric', schema=None) as batch_op:
|
||||||
|
batch_op.drop_index(batch_op.f('ix_fabric_name'))
|
||||||
|
batch_op.drop_index(batch_op.f('ix_fabric_id'))
|
||||||
|
|
||||||
|
op.drop_table('fabric')
|
||||||
|
with op.batch_alter_table('doc_types', schema=None) as batch_op:
|
||||||
|
batch_op.drop_index(batch_op.f('ix_doc_types_name'))
|
||||||
|
batch_op.drop_index(batch_op.f('ix_doc_types_id'))
|
||||||
|
|
||||||
|
op.drop_table('doc_types')
|
||||||
|
with op.batch_alter_table('accountant_settings', schema=None) as batch_op:
|
||||||
|
batch_op.drop_index(batch_op.f('ix_accountant_settings_name'))
|
||||||
|
batch_op.drop_index(batch_op.f('ix_accountant_settings_id'))
|
||||||
|
|
||||||
|
op.drop_table('accountant_settings')
|
||||||
|
# ### end Alembic commands ###
|
||||||
40
src/migrations/versions/8c300c4d43ea_.py
Normal file
40
src/migrations/versions/8c300c4d43ea_.py
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
"""empty message
|
||||||
|
|
||||||
|
Revision ID: 8c300c4d43ea
|
||||||
|
Revises: 439a77f8a4d4
|
||||||
|
Create Date: 2026-07-22 15:20:34.871724
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = '8c300c4d43ea'
|
||||||
|
down_revision: Union[str, Sequence[str], None] = '439a77f8a4d4'
|
||||||
|
branch_labels: Union[str, Sequence[str], None] = None
|
||||||
|
depends_on: Union[str, Sequence[str], None] = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
"""Upgrade schema."""
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
with op.batch_alter_table('reports', schema=None) as batch_op:
|
||||||
|
batch_op.alter_column('uploaded_at',
|
||||||
|
existing_type=sa.TIMESTAMP(),
|
||||||
|
nullable=True)
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
"""Downgrade schema."""
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
with op.batch_alter_table('reports', schema=None) as batch_op:
|
||||||
|
batch_op.alter_column('uploaded_at',
|
||||||
|
existing_type=sa.TIMESTAMP(),
|
||||||
|
nullable=False)
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
||||||
4
src/models/database_models/__init__.py
Normal file
4
src/models/database_models/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
from .files import Stored, Markets
|
||||||
|
from .model import Model
|
||||||
|
from .goods import Nomenclature, DocumentTypes, Fabric
|
||||||
|
from .accountant import AccountantSettings
|
||||||
14
src/models/database_models/accountant.py
Normal file
14
src/models/database_models/accountant.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
from src.models.database_models.model import Model
|
||||||
|
from sqlalchemy import String
|
||||||
|
from sqlalchemy.orm import Mapped, mapped_column
|
||||||
|
from uuid import UUID, uuid1
|
||||||
|
|
||||||
|
class AccountantSettings(Model):
|
||||||
|
__tablename__="accountant_settings"
|
||||||
|
|
||||||
|
id:Mapped[int]=mapped_column(primary_key=True, index=True)
|
||||||
|
name:Mapped[str]=mapped_column(String(64),unique=True, index=True)
|
||||||
|
database_key:Mapped[UUID]=mapped_column(default=uuid1, unique=True)
|
||||||
|
|
||||||
|
def __repr__(self) -> str:
|
||||||
|
return f'ID: {self.id}, Name: {self.name}'
|
||||||
43
src/models/database_models/files.py
Normal file
43
src/models/database_models/files.py
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
from datetime import datetime
|
||||||
|
from sqlalchemy import TIMESTAMP, String, func, ForeignKey
|
||||||
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
from src.models.database_models.model import Model
|
||||||
|
from uuid import UUID, uuid1
|
||||||
|
|
||||||
|
|
||||||
|
class Stored(Model):
|
||||||
|
__tablename__="reports"
|
||||||
|
|
||||||
|
id:Mapped[int]=mapped_column(primary_key=True, index=True)
|
||||||
|
doc_id:Mapped[UUID]=mapped_column(default=uuid1, unique=True)
|
||||||
|
filename:Mapped[str]=mapped_column(String(255), index=True)
|
||||||
|
created_at:Mapped[datetime]=mapped_column(TIMESTAMP, server_default=func.now())
|
||||||
|
uploaded_at:Mapped[datetime]=mapped_column(TIMESTAMP,onupdate=func.now(), nullable=True)
|
||||||
|
doc_date:Mapped[datetime]=mapped_column(TIMESTAMP)
|
||||||
|
status:Mapped[str]=mapped_column(String(64))
|
||||||
|
user_id:Mapped[UUID]=mapped_column(ForeignKey("users.id", ondelete="CASCADE"), index=True)
|
||||||
|
market_id:Mapped[int]=mapped_column(ForeignKey("markets.id", ondelete="CASCADE"),index=True)
|
||||||
|
|
||||||
|
|
||||||
|
user:Mapped["User"]=relationship(back_populates="report")
|
||||||
|
market:Mapped["Markets"]=relationship(back_populates="report")
|
||||||
|
def __repr__(self) -> str:
|
||||||
|
return f'ID: {self.id}, Filename: {self.filename}, Status: {self.status}'
|
||||||
|
|
||||||
|
class Markets(Model):
|
||||||
|
__tablename__="markets"
|
||||||
|
|
||||||
|
id:Mapped[int]=mapped_column(primary_key=True, index=True)
|
||||||
|
name:Mapped[str]=mapped_column(String(64), unique=True)
|
||||||
|
|
||||||
|
report:Mapped[list["Stored"]]=relationship(back_populates="market")
|
||||||
|
def __repr__(self) -> str:
|
||||||
|
return f'ID: {self.id}, Name: {self.name}'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
42
src/models/database_models/goods.py
Normal file
42
src/models/database_models/goods.py
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
from decimal import Decimal
|
||||||
|
from src.models.database_models.model import Model
|
||||||
|
from sqlalchemy import Boolean, ForeignKey, Integer, Numeric, String
|
||||||
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||||
|
|
||||||
|
class Nomenclature(Model):
|
||||||
|
__tablename__="goods"
|
||||||
|
|
||||||
|
id:Mapped[int]=mapped_column(primary_key=True, index=True)
|
||||||
|
article:Mapped[str]=mapped_column(String(16), unique=True, index=True)
|
||||||
|
price:Mapped[Decimal]=mapped_column(Numeric(10, 2), index=True)
|
||||||
|
tnvd:Mapped[int]=mapped_column(Integer, index=True, unique=True)
|
||||||
|
doc_type_id:Mapped[int]=mapped_column(ForeignKey("doc_types.id", ondelete="CASCADE"), index=True)
|
||||||
|
fabric_id:Mapped[int]=mapped_column(ForeignKey("fabric.id", ondelete="CASCADE"), index=True)
|
||||||
|
status:Mapped[bool]=mapped_column(Boolean)
|
||||||
|
|
||||||
|
doc_type:Mapped["DocumentTypes"]=relationship(back_populates="good")
|
||||||
|
fabric:Mapped["Fabric"]=relationship(back_populates="good")
|
||||||
|
|
||||||
|
def __repr__(self) -> str:
|
||||||
|
return f'ID: {self.id}, Article: {self.article}, Price: {self.price}'
|
||||||
|
class DocumentTypes(Model):
|
||||||
|
__tablename__="doc_types"
|
||||||
|
|
||||||
|
id:Mapped[int]=mapped_column(primary_key=True, index=True)
|
||||||
|
name:Mapped[str]=mapped_column(String(64), unique=True, index=True)
|
||||||
|
|
||||||
|
good:Mapped[list["Nomenclature"]]=relationship(back_populates="doc_type")
|
||||||
|
|
||||||
|
def __repr__(self) -> str:
|
||||||
|
return f'ID: {self.id}, Name:{self.name}'
|
||||||
|
|
||||||
|
class Fabric(Model):
|
||||||
|
__tablename__="fabric"
|
||||||
|
|
||||||
|
id:Mapped[int]=mapped_column(primary_key=True, index=True)
|
||||||
|
name:Mapped[str]=mapped_column(String(64),unique=True, index=True)
|
||||||
|
|
||||||
|
|
||||||
|
good:Mapped[list["Nomenclature"]]=relationship(back_populates="fabric")
|
||||||
|
def __repr__(self) -> str:
|
||||||
|
return f"ID: {self.id}, Name: {self.name}"
|
||||||
101
src/models/database_models/model.py
Normal file
101
src/models/database_models/model.py
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
from sqlalchemy import TIMESTAMP, Table, create_engine, String, Boolean, MetaData, Column, ForeignKey, func
|
||||||
|
from sqlalchemy.orm import Mapped, mapped_column, DeclarativeBase, relationship
|
||||||
|
from uuid import UUID, uuid4
|
||||||
|
from datetime import datetime
|
||||||
|
engine = create_engine("sqlite:///DB/database.db", echo=True)
|
||||||
|
|
||||||
|
'''remember as a boilerplate, or just cp/pst'''
|
||||||
|
class Model(DeclarativeBase):
|
||||||
|
metadata = MetaData(naming_convention={
|
||||||
|
"ix": "ix_%(column_0_label)s",
|
||||||
|
"uq": "uq_%(table_name)s_%(column_0_name)s",
|
||||||
|
"ck": "ck_%(table_name)s_%(constraint_name)s",
|
||||||
|
"fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
|
||||||
|
"pk": "pk_%(table_name)s",
|
||||||
|
})
|
||||||
|
|
||||||
|
class User(Model):
|
||||||
|
__tablename__ = "users"
|
||||||
|
|
||||||
|
id:Mapped[UUID] = mapped_column(default=uuid4,primary_key=True)
|
||||||
|
first_name:Mapped[str] = mapped_column(String(64), index=True)
|
||||||
|
last_name:Mapped[str]=mapped_column(String(64), index=True)
|
||||||
|
middle_name:Mapped[str]=mapped_column(String(64), index=True)
|
||||||
|
email:Mapped[str]=mapped_column(String(255), index=True, unique=True)
|
||||||
|
status:Mapped[bool]=mapped_column(Boolean, default=True)
|
||||||
|
hashed_password:Mapped[str]=mapped_column(String(255))
|
||||||
|
|
||||||
|
group:Mapped[list['PermissionsGroups']]=relationship(secondary="user_group", back_populates="user", lazy="selectin")
|
||||||
|
|
||||||
|
direct_permissions:Mapped[list['Permissions']]=relationship(secondary="user_direct_permissions", back_populates="users_direct")
|
||||||
|
|
||||||
|
refresh_token:Mapped[list['RefreshTokens']]=relationship(back_populates="user")
|
||||||
|
report:Mapped[list["Stored"]]=relationship(back_populates="user")
|
||||||
|
def __repr__(self) -> str:
|
||||||
|
return f"ID: {self.id}, Name: {self.first_name}, Status: {self.status}"
|
||||||
|
|
||||||
|
class PermissionsGroups(Model):
|
||||||
|
__tablename__="groups_of_permissions"
|
||||||
|
|
||||||
|
id:Mapped[int]=mapped_column(primary_key=True, index=True)
|
||||||
|
group:Mapped[str]=mapped_column(String(255), unique=True)
|
||||||
|
|
||||||
|
user:Mapped[list['User']]=relationship(secondary="user_group", back_populates="group")
|
||||||
|
permissions:Mapped[list["Permissions"]]=relationship(secondary="group_permission", back_populates="group", lazy="selectin")
|
||||||
|
|
||||||
|
def __repr__(self)->str:
|
||||||
|
return f"ID: {self.id}, Permissions: {self.group}"
|
||||||
|
|
||||||
|
class Permissions(Model):
|
||||||
|
__tablename__ = "permissions"
|
||||||
|
|
||||||
|
id:Mapped[int]=mapped_column(primary_key=True, index=True)
|
||||||
|
permission:Mapped[str]=mapped_column(String(255), unique=True)
|
||||||
|
|
||||||
|
group:Mapped[list['PermissionsGroups']]=relationship(secondary="group_permission", back_populates="permissions")
|
||||||
|
users_direct:Mapped[list["User"]]=relationship(secondary="user_direct_permissions", back_populates="direct_permissions")
|
||||||
|
|
||||||
|
def __repr__(self)->str:
|
||||||
|
return f"ID: {self.id}, Permissions: {self.permission}"
|
||||||
|
|
||||||
|
user_group_of_permissions=Table(
|
||||||
|
"user_group",
|
||||||
|
Model.metadata,
|
||||||
|
Column("user_id", ForeignKey("users.id"), primary_key=True),
|
||||||
|
Column("permission_group_id", ForeignKey("groups_of_permissions.id"), primary_key=True)
|
||||||
|
)
|
||||||
|
|
||||||
|
user_permission=Table(
|
||||||
|
"user_direct_permissions",
|
||||||
|
Model.metadata,
|
||||||
|
Column("user_id",ForeignKey("users.id"), primary_key=True),
|
||||||
|
Column("permission_id", ForeignKey("permissions.id"), primary_key=True)
|
||||||
|
)
|
||||||
|
|
||||||
|
group_permission = Table(
|
||||||
|
"group_permission",
|
||||||
|
Model.metadata,
|
||||||
|
Column("group_id", ForeignKey("groups_of_permissions.id"), primary_key=True),
|
||||||
|
Column("permission_id", ForeignKey("permissions.id"), primary_key=True),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class RefreshTokens(Model):
|
||||||
|
|
||||||
|
__tablename__= "refresh_tokens"
|
||||||
|
|
||||||
|
id:Mapped[int]=mapped_column(primary_key=True, index=True)
|
||||||
|
user_id:Mapped[UUID]=mapped_column(ForeignKey("users.id", ondelete="CASCADE"), index=True)
|
||||||
|
token_hash:Mapped[str]=mapped_column(String(255), unique=True)
|
||||||
|
device_info:Mapped[str]=mapped_column(String(255))
|
||||||
|
ip_address:Mapped[str]=mapped_column(String(45))
|
||||||
|
is_revoked:Mapped[bool]=mapped_column(Boolean, default=False)
|
||||||
|
|
||||||
|
expires_at:Mapped[datetime]=mapped_column(TIMESTAMP)
|
||||||
|
created_at:Mapped[datetime]=mapped_column(TIMESTAMP, server_default=func.now())
|
||||||
|
replaced_by:Mapped[int|None]=mapped_column(ForeignKey("refresh_tokens.id"), nullable=True, default=None)
|
||||||
|
|
||||||
|
|
||||||
|
user:Mapped["User"]=relationship(back_populates="refresh_token")
|
||||||
|
def __repr__(self)->str:
|
||||||
|
return f'ID: {self.id}, USER_ID: {self.user_id}, Is_revoked: {self.is_revoked}, Token_Hash: {self.token_hash}'
|
||||||
9
src/models/pydantic_models/accountant.py
Normal file
9
src/models/pydantic_models/accountant.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
from typing import Annotated
|
||||||
|
from src.models.pydantic_models.model import Base
|
||||||
|
from pydantic import Field
|
||||||
|
from uuid import UUID
|
||||||
|
class AccountantCreate(Base):
|
||||||
|
|
||||||
|
name:Annotated[str, Field(...,max_length=64,description="name of the accountant setting")]
|
||||||
|
database_key:Annotated[UUID, Field(..., description="database key from the 1C server")]
|
||||||
|
|
||||||
26
src/models/pydantic_models/files.py
Normal file
26
src/models/pydantic_models/files.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
from datetime import datetime
|
||||||
|
from typing import Annotated
|
||||||
|
from uuid import UUID
|
||||||
|
from src.models.pydantic_models.model import Base
|
||||||
|
from pydantic import Field
|
||||||
|
|
||||||
|
class ReportCreate(Base):
|
||||||
|
filename:Annotated[str,Field(..., min_length=2, max_length=255, description="name of the report")]
|
||||||
|
doc_date:Annotated[datetime, Field(..., description="ts of the report")]
|
||||||
|
status:Annotated[str, Field(..., max_length=64, description="status of the report (uploaded,finalized, failed)")]
|
||||||
|
user:Annotated[UUID, Field(..., description="id of the user author")]
|
||||||
|
market:Annotated[str, Field(..., max_length=64,description="name of the market")]
|
||||||
|
|
||||||
|
class ReportOut(Base):
|
||||||
|
filename:Annotated[str,Field(..., min_length=2, max_length=255, description="name of the report")]
|
||||||
|
doc_date:Annotated[datetime, Field(..., description="ts of the report")]
|
||||||
|
status:Annotated[str, Field(..., max_length=64, description="status of the report (uploaded,finalized, failed)")]
|
||||||
|
user:Annotated[UUID, Field(..., description="id of the user author")]
|
||||||
|
market:Annotated[str, Field(..., max_length=64, description="name of the market")]
|
||||||
|
|
||||||
|
|
||||||
|
class MarketCreate(Base):
|
||||||
|
name:Annotated[str, Field(..., max_length=64,description="certificate or declaration")]
|
||||||
|
|
||||||
|
class MarketOut(Base):
|
||||||
|
name:Annotated[str, Field(..., max_length=64,description="certificate or declaration")]
|
||||||
35
src/models/pydantic_models/goods.py
Normal file
35
src/models/pydantic_models/goods.py
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
from decimal import Decimal
|
||||||
|
from src.models.pydantic_models.model import Base
|
||||||
|
from pydantic import Field
|
||||||
|
from typing import Annotated
|
||||||
|
|
||||||
|
class NomenclatureCreate(Base):
|
||||||
|
|
||||||
|
article:Annotated[str, Field(...,min_length=5,max_length=16, description="name of the article")]
|
||||||
|
price:Annotated[Decimal, Field(..., max_digits=12, description="price of the article")]
|
||||||
|
tnvd:Annotated[int, Field(..., max_digits=10, description="tnvd from the Markirovka.crpt")]
|
||||||
|
status:Annotated[bool, Field(..., description="status of the article")]
|
||||||
|
|
||||||
|
doc_type:Annotated[str, Field(..., description="document type (declaration or certificate)")]
|
||||||
|
fabric:Annotated[str, Field(..., description="fabric of the product")]
|
||||||
|
|
||||||
|
class NomenclatureOut(Base):
|
||||||
|
article:Annotated[str, Field(..., min_length=5,max_length=16, description="name of the article")]
|
||||||
|
price:Annotated[Decimal, Field(..., max_digits=12,description="price of the article")]
|
||||||
|
tnvd:Annotated[int, Field(..., max_digits=10,description="tnvd from the Markirovka.crpt")]
|
||||||
|
status:Annotated[bool, Field(..., description="status of the article")]
|
||||||
|
|
||||||
|
doc_type:Annotated[str, Field(...,max_length=64, description="document type (declaration or certificate)")]
|
||||||
|
fabric:Annotated[str, Field(...,max_length=64, description="fabric of the product")]
|
||||||
|
|
||||||
|
class DocumentTypeCreate(Base):
|
||||||
|
name:Annotated[str, Field(...,max_length=64, description="certificate or declaration")]
|
||||||
|
|
||||||
|
class DocumentTypeOut(Base):
|
||||||
|
name:Annotated[str, Field(..., max_length=64,description="certificate or declaration")]
|
||||||
|
|
||||||
|
class FabricCreate(Base):
|
||||||
|
name:Annotated[str, Field(..., max_length=64,description="certificate or declaration")]
|
||||||
|
|
||||||
|
class FabricOut(Base):
|
||||||
|
name:Annotated[str, Field(..., max_length=64,description="certificate or declaration")]
|
||||||
77
src/models/pydantic_models/model.py
Normal file
77
src/models/pydantic_models/model.py
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
from datetime import datetime
|
||||||
|
from typing import Annotated
|
||||||
|
from pydantic import BaseModel, EmailStr, Field
|
||||||
|
from uuid import UUID
|
||||||
|
|
||||||
|
|
||||||
|
class Base(BaseModel):
|
||||||
|
model_config = {"from_attributes": True}
|
||||||
|
|
||||||
|
class UserCreate(Base):
|
||||||
|
|
||||||
|
first_name:Annotated[str, Field(..., max_length=64,description="first name of the user")]
|
||||||
|
last_name:Annotated[str, Field(...,max_length=64, description="last name of the user")]
|
||||||
|
middle_name:Annotated[str, Field(...,max_length=64, description="middle name of the user")]
|
||||||
|
email:Annotated[EmailStr, Field(...,min_length=5, max_length=255, description="email of the user")]
|
||||||
|
plain_password:Annotated[str, Field(...,min_length=8,max_length=72, description="plain password of the user")]
|
||||||
|
status:Annotated[bool, Field(..., description="status of the user")]
|
||||||
|
permissions:Annotated[list[str], Field(..., description="permissions of the user")]
|
||||||
|
permission_groups:Annotated[list[str], Field(..., description="permissions groups of the user")]
|
||||||
|
|
||||||
|
class UserOut(Base):
|
||||||
|
|
||||||
|
id:Annotated[UUID, Field(..., description="Id of the user")]
|
||||||
|
first_name:Annotated[str, Field(..., max_length=64,description="first name of the user")]
|
||||||
|
last_name:Annotated[str, Field(..., max_length=64,description="last name of the user")]
|
||||||
|
middle_name:Annotated[str, Field(..., max_length=64, description="middle name of the user")]
|
||||||
|
email:Annotated[EmailStr, Field(...,min_length=5, max_length=255, description="email of the user")]
|
||||||
|
status:Annotated[bool, Field(..., description="status of the user")]
|
||||||
|
permissions:Annotated[list[str], Field(..., description="permissions of the user")]
|
||||||
|
permission_groups:Annotated[list[str], Field(..., description="permissions groups of the user")]
|
||||||
|
|
||||||
|
|
||||||
|
class UserUpdate(Base):
|
||||||
|
|
||||||
|
first_name:Annotated[str|None, Field(None, max_length=64, description="first name of the user")]
|
||||||
|
last_name:Annotated[str|None, Field(None, max_length=64,description="last name of the user")]
|
||||||
|
middle_name:Annotated[str|None, Field(None, max_length=64,description="middle name of the user")]
|
||||||
|
email:Annotated[EmailStr|None, Field(None, min_length=5, max_length=255, description="email of the user")]
|
||||||
|
status:Annotated[bool|None, Field(None, description="status of the user")]
|
||||||
|
permissions:Annotated[list[str]|None, Field(None, description="permissions of the user")]
|
||||||
|
permission_groups:Annotated[list[str]|None, Field(None, description="permissions groups of the user")]
|
||||||
|
|
||||||
|
class PermissionsCreate(Base):
|
||||||
|
permission:Annotated[str, Field(..., max_length=30, description="permission name")]
|
||||||
|
|
||||||
|
|
||||||
|
class PermissionsOut(Base):
|
||||||
|
permission:Annotated[str, Field(..., max_length=30, description="permission name")]
|
||||||
|
|
||||||
|
|
||||||
|
class PermissionsGroupsCreate(Base):
|
||||||
|
|
||||||
|
group:Annotated[str, Field(..., max_length=255, description="group name for the permissions")]
|
||||||
|
|
||||||
|
|
||||||
|
class PermissionsGroupsOut(Base):
|
||||||
|
|
||||||
|
group:Annotated[str, Field(..., max_length=255, description="group name for the permissions")]
|
||||||
|
|
||||||
|
|
||||||
|
class RefreshTokensCreate(Base):
|
||||||
|
|
||||||
|
user_id:Annotated[UUID, Field(..., description="foreign key for the user")]
|
||||||
|
token_hash:Annotated[str, Field(...,max_length=255, description="token hash")]
|
||||||
|
device_info:Annotated[str, Field(...,max_length=255, description="User device info")]
|
||||||
|
ip_address:Annotated[str, Field(...,max_length=45, description="ip v4/v6 of the user")]
|
||||||
|
is_revoked:Annotated[bool|None, Field(None, description="revoke token if logout was made")]
|
||||||
|
expires_at:Annotated[datetime, Field(..., description="when token is going to be expired")]
|
||||||
|
|
||||||
|
class RefreshTokensOut(Base):
|
||||||
|
|
||||||
|
user_id:Annotated[UUID, Field(..., description="foreign key for the user")]
|
||||||
|
token_hash:Annotated[str, Field(..., max_length=255,description="token hash")]
|
||||||
|
device_info:Annotated[str, Field(..., max_length=255, description="User device info")]
|
||||||
|
ip_address:Annotated[str, Field(...,max_length=45, description="ip v4/v6 of the user")]
|
||||||
|
is_revoked:Annotated[bool|None, Field(None, description="revoke token if logout was made")]
|
||||||
|
expires_at:Annotated[datetime, Field(..., description="when token is going to be expired")]
|
||||||
1
src/service/__init__.py
Normal file
1
src/service/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
'''business logic'''
|
||||||
Reference in New Issue
Block a user