From 3d6b37f0a5048746f7830582caec38f4c59dc139 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Sun, 31 Jul 2022 13:22:11 +0200 Subject: [PATCH] [plugins] Add missing IDs and fix initial migration file Signed-off-by: Ferdinand Thiessen --- .../255b93b6beed_flaschengeist_initial.py | 17 ++++++++++++----- flaschengeist/models/image.py | 10 +++++----- flaschengeist/models/setting.py | 4 ++-- flaschengeist/plugins/roles/__init__.py | 1 + flaschengeist/plugins/scheduler.py | 2 ++ flaschengeist/plugins/users/__init__.py | 1 + 6 files changed, 23 insertions(+), 12 deletions(-) diff --git a/flaschengeist/alembic/migrations/255b93b6beed_flaschengeist_initial.py b/flaschengeist/alembic/migrations/255b93b6beed_flaschengeist_initial.py index b7deac6..b18a71e 100644 --- a/flaschengeist/alembic/migrations/255b93b6beed_flaschengeist_initial.py +++ b/flaschengeist/alembic/migrations/255b93b6beed_flaschengeist_initial.py @@ -18,14 +18,21 @@ depends_on = None def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### + op.create_table( + "plugin_setting", + sa.Column("id", flaschengeist.models.Serial(), nullable=False), + sa.Column("plugin", sa.String(length=127), nullable=True), + sa.Column("name", sa.String(length=127), nullable=False), + sa.Column("value", sa.PickleType(protocol=4), nullable=True), + sa.PrimaryKeyConstraint("id", name=op.f("pk_plugin_setting")), + ) op.create_table( "image", sa.Column("id", flaschengeist.models.Serial(), nullable=False), - sa.Column("filename_", sa.String(length=127), nullable=False), - sa.Column("mimetype_", sa.String(length=30), nullable=False), - sa.Column("thumbnail_", sa.String(length=127), nullable=True), - sa.Column("path_", sa.String(length=127), nullable=True), + sa.Column("filename", sa.String(length=255), nullable=False), + sa.Column("mimetype", sa.String(length=127), nullable=False), + sa.Column("thumbnail", sa.String(length=255), nullable=True), + sa.Column("path", sa.String(length=255), nullable=True), sa.PrimaryKeyConstraint("id", name=op.f("pk_image")), ) op.create_table( diff --git a/flaschengeist/models/image.py b/flaschengeist/models/image.py index 4c963e7..9a97ea8 100644 --- a/flaschengeist/models/image.py +++ b/flaschengeist/models/image.py @@ -9,11 +9,11 @@ from ..database import db class Image(db.Model, ModelSerializeMixin): __tablename__ = "image" - id: int = db.Column("id", Serial, primary_key=True) - filename_: str = db.Column(db.String(127), nullable=False) - mimetype_: str = db.Column(db.String(30), nullable=False) - thumbnail_: str = db.Column(db.String(127)) - path_: str = db.Column(db.String(127)) + id: int = db.Column(Serial, primary_key=True) + filename_: str = db.Column("filename", db.String(255), nullable=False) + mimetype_: str = db.Column("mimetype", db.String(127), nullable=False) + thumbnail_: str = db.Column("thumbnail", db.String(255)) + path_: str = db.Column("path", db.String(255)) def open(self): return open(self.path_, "rb") diff --git a/flaschengeist/models/setting.py b/flaschengeist/models/setting.py index 277f36c..b090c3e 100644 --- a/flaschengeist/models/setting.py +++ b/flaschengeist/models/setting.py @@ -8,6 +8,6 @@ from ..database import db class _PluginSetting(db.Model): __tablename__ = "plugin_setting" id = db.Column("id", Serial, primary_key=True) - plugin: str = db.Column(db.String(30)) - name: str = db.Column(db.String(30), nullable=False) + plugin: str = db.Column(db.String(127)) + name: str = db.Column(db.String(127), nullable=False) value: Any = db.Column(db.PickleType(protocol=4)) diff --git a/flaschengeist/plugins/roles/__init__.py b/flaschengeist/plugins/roles/__init__.py index 4e3c92b..477f956 100644 --- a/flaschengeist/plugins/roles/__init__.py +++ b/flaschengeist/plugins/roles/__init__.py @@ -16,6 +16,7 @@ from . import permissions class RolesPlugin(Plugin): + id = "roles" blueprint = Blueprint("roles", __name__) permissions = permissions.permissions diff --git a/flaschengeist/plugins/scheduler.py b/flaschengeist/plugins/scheduler.py index 7d15b69..55870b8 100644 --- a/flaschengeist/plugins/scheduler.py +++ b/flaschengeist/plugins/scheduler.py @@ -39,6 +39,8 @@ def scheduled(id: str, replace=False, **kwargs): class SchedulerPlugin(Plugin): + id = "scheduler" + def __init__(self, entry_point, config=None): super().__init__(entry_point, config) self.blueprint = Blueprint(self.name, __name__) diff --git a/flaschengeist/plugins/users/__init__.py b/flaschengeist/plugins/users/__init__.py index 2e0802c..a76c009 100644 --- a/flaschengeist/plugins/users/__init__.py +++ b/flaschengeist/plugins/users/__init__.py @@ -18,6 +18,7 @@ from flaschengeist.utils.datetime import from_iso_format class UsersPlugin(Plugin): + id = "users" blueprint = Blueprint("users", __name__) permissions = permissions.permissions