add .gitignore, remove pycache
This commit is contained in:
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
__pycache__
|
||||||
|
/backend/.venv
|
||||||
|
.env
|
||||||
|
.pytest_cache
|
||||||
|
/backend/logs
|
||||||
|
.DS_Store
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,4 +1,3 @@
|
|||||||
from sqlmodel import select
|
|
||||||
from sqlmodel.ext.asyncio.session import AsyncSession
|
from sqlmodel.ext.asyncio.session import AsyncSession
|
||||||
from sqlalchemy.ext.asyncio import create_async_engine
|
from sqlalchemy.ext.asyncio import create_async_engine
|
||||||
from sqlalchemy.orm import sessionmaker
|
from sqlalchemy.orm import sessionmaker
|
||||||
@@ -14,20 +13,6 @@ async_session = sessionmaker[AsyncSession](
|
|||||||
async_engine, class_=AsyncSession, expire_on_commit=False
|
async_engine, class_=AsyncSession, expire_on_commit=False
|
||||||
)
|
)
|
||||||
|
|
||||||
async def init_db(session: AsyncSession) -> None:
|
|
||||||
|
|
||||||
from app.models import User, Language,Role
|
|
||||||
|
|
||||||
user = (await session.exec(
|
|
||||||
select(User).where(User.id == config.ADMIN_TELEGRAM_ID)
|
|
||||||
)).first()
|
|
||||||
if not user:
|
|
||||||
await User.create(session, User(
|
|
||||||
id = config.ADMIN_TELEGRAM_ID,
|
|
||||||
lang = Language.DEFAULT,
|
|
||||||
roles = [Role.SUPER_USER],
|
|
||||||
name = "Admin"), commit = True)
|
|
||||||
|
|
||||||
async def get_db() -> AsyncSession: # type: ignore
|
async def get_db() -> AsyncSession: # type: ignore
|
||||||
async with async_session() as session:
|
async with async_session() as session:
|
||||||
yield session
|
yield session
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -61,6 +61,7 @@ class _BaseEntityDescriptor:
|
|||||||
item_caption_btn: EntityItemCaptionCallable | None = None
|
item_caption_btn: EntityItemCaptionCallable | None = None
|
||||||
show_in_entities_menu: bool = True
|
show_in_entities_menu: bool = True
|
||||||
field_sequence: list[str] = None
|
field_sequence: list[str] = None
|
||||||
|
edit_buttons: list[list[str]] = None
|
||||||
permissions: dict[EntityPermission, list[RoleBase]] = field(default_factory = lambda: {
|
permissions: dict[EntityPermission, list[RoleBase]] = field(default_factory = lambda: {
|
||||||
EntityPermission.LIST: [RoleBase.DEFAULT_USER, RoleBase.SUPER_USER],
|
EntityPermission.LIST: [RoleBase.DEFAULT_USER, RoleBase.SUPER_USER],
|
||||||
EntityPermission.READ: [RoleBase.DEFAULT_USER, RoleBase.SUPER_USER],
|
EntityPermission.READ: [RoleBase.DEFAULT_USER, RoleBase.SUPER_USER],
|
||||||
|
|||||||
@@ -3,4 +3,4 @@ from .bot_enum import BotEnum, EnumMember
|
|||||||
|
|
||||||
class LanguageBase(BotEnum):
|
class LanguageBase(BotEnum):
|
||||||
|
|
||||||
DEFAULT = EnumMember("en", {"en": "🇬🇧 english"})
|
EN = EnumMember("en", {"en": "🇬🇧 english"})
|
||||||
@@ -23,7 +23,7 @@ class SettingsMetaclass(type):
|
|||||||
if base_classes:
|
if base_classes:
|
||||||
settings_descriptors = base_classes[0].__dict__.get("_settings_descriptors", {})
|
settings_descriptors = base_classes[0].__dict__.get("_settings_descriptors", {})
|
||||||
|
|
||||||
for annotation in attributes['__annotations__']:
|
for annotation in attributes.get('__annotations__', {}):
|
||||||
|
|
||||||
if annotation in ["_settings_descriptors", "_cache", "_cached_settings"]:
|
if annotation in ["_settings_descriptors", "_cache", "_cached_settings"]:
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class UserBase(BotEntity, table = False):
|
|||||||
|
|
||||||
__tablename__ = "user"
|
__tablename__ = "user"
|
||||||
|
|
||||||
lang: LanguageBase = Field(sa_type = EnumType(LanguageBase), default = LanguageBase.DEFAULT)
|
lang: LanguageBase = Field(sa_type = EnumType(LanguageBase), default = LanguageBase.EN)
|
||||||
is_active: bool = True
|
is_active: bool = True
|
||||||
|
|
||||||
roles: list[RoleBase] = Field(sa_type=ARRAY(EnumType(RoleBase)), default = [RoleBase.DEFAULT_USER])
|
roles: list[RoleBase] = Field(sa_type=ARRAY(EnumType(RoleBase)), default = [RoleBase.DEFAULT_USER])
|
||||||
Binary file not shown.
Reference in New Issue
Block a user