From 2796a626e07a8573200e4a6b9f61688bb99c3075 Mon Sep 17 00:00:00 2001 From: Eugen Ciur Date: Sun, 17 Nov 2024 13:31:04 +0100 Subject: [PATCH] update logo --- artwork/logo.svg | 85 +++++++++++++++++++ ...n.py => 7bd65feeece1_initial_migration.py} | 10 ++- papermerge/core/features/users/cli/cli.py | 23 +++-- papermerge/core/features/users/db/orm.py | 6 +- 4 files changed, 109 insertions(+), 15 deletions(-) create mode 100644 artwork/logo.svg rename papermerge/core/alembic/versions/{76daa802d8cc_initial_migration.py => 7bd65feeece1_initial_migration.py} (97%) diff --git a/artwork/logo.svg b/artwork/logo.svg new file mode 100644 index 000000000..2157776d1 --- /dev/null +++ b/artwork/logo.svg @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + diff --git a/papermerge/core/alembic/versions/76daa802d8cc_initial_migration.py b/papermerge/core/alembic/versions/7bd65feeece1_initial_migration.py similarity index 97% rename from papermerge/core/alembic/versions/76daa802d8cc_initial_migration.py rename to papermerge/core/alembic/versions/7bd65feeece1_initial_migration.py index 9a7df5608..7df0ec8dc 100644 --- a/papermerge/core/alembic/versions/76daa802d8cc_initial_migration.py +++ b/papermerge/core/alembic/versions/7bd65feeece1_initial_migration.py @@ -1,8 +1,8 @@ """Initial migration -Revision ID: 76daa802d8cc +Revision ID: 7bd65feeece1 Revises: -Create Date: 2024-11-14 08:17:32.471311 +Create Date: 2024-11-17 13:26:28.809195 """ from typing import Sequence, Union @@ -12,7 +12,7 @@ # revision identifiers, used by Alembic. -revision: str = '76daa802d8cc' +revision: str = '7bd65feeece1' down_revision: Union[str, None] = None branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None @@ -92,7 +92,9 @@ def upgrade() -> None: sa.Column('updated_at', sa.DateTime(), nullable=False), sa.ForeignKeyConstraint(['home_folder_id'], ['folders.node_id'], ondelete='CASCADE', deferrable=True), sa.ForeignKeyConstraint(['inbox_folder_id'], ['folders.node_id'], ondelete='CASCADE', deferrable=True), - sa.PrimaryKeyConstraint('id') + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('email'), + sa.UniqueConstraint('username') ) op.create_table('custom_fields', sa.Column('id', sa.Uuid(), nullable=False), diff --git a/papermerge/core/features/users/cli/cli.py b/papermerge/core/features/users/cli/cli.py index 87ea34fd8..6382731a3 100644 --- a/papermerge/core/features/users/cli/cli.py +++ b/papermerge/core/features/users/cli/cli.py @@ -1,5 +1,7 @@ from typing import Sequence +from prompt_toolkit import prompt +from typing_extensions import Annotated import typer from rich.console import Console from rich.table import Table @@ -28,20 +30,25 @@ def list_users(page_size: int = 10, page_number: int = 1): print_users(users.items) +Username = Annotated[ + str, typer.Option(prompt=True, envvar="PAPERMERGE__AUTH__USERNAME") +] +Email = Annotated[str, typer.Option(envvar="PAPERMERGE__AUTH__EMAIL")] +Password = Annotated[ + str, typer.Option(prompt=True, envvar="PAPERMERGE__AUTH__PASSWORD") +] + + @app.command(name="create") def create_user_cmd( - username: str, + username: Username, + password: Password, + email: Email = None, superuser: bool = False, - password: str | None = None, - email: str | None = None, ): """Create user""" - - if password is None: - password = username - if email is None: - email = f"{username}@papermerge.com" + email = f"{username}@example.com" with db.Session() as db_session: user, error = usr_dbapi.create_user( diff --git a/papermerge/core/features/users/db/orm.py b/papermerge/core/features/users/db/orm.py index 7395a0784..03a1566e4 100644 --- a/papermerge/core/features/users/db/orm.py +++ b/papermerge/core/features/users/db/orm.py @@ -16,9 +16,9 @@ class User(Base): __tablename__ = "users" id: Mapped[UUID] = mapped_column(primary_key=True, insert_default=uuid.uuid4()) - username: Mapped[str] - email: Mapped[str] - password: Mapped[str] + username: Mapped[str] = mapped_column(unique=True) + email: Mapped[str] = mapped_column(unique=True) + password: Mapped[str] = mapped_column(nullable=False) first_name: Mapped[str] = mapped_column(default=" ") last_name: Mapped[str] = mapped_column(default=" ") is_superuser: Mapped[bool] = mapped_column(default=False)