From f33aaadce79f2d141fa8a91c465e91b65cdab9f2 Mon Sep 17 00:00:00 2001 From: Thomas Peetz Date: Mon, 3 Feb 2025 17:37:19 +0100 Subject: [PATCH] fix problem with closing subwindows and define field length for id in schema --- python/kontor-gui/gui/main_window.py | 4 ++-- python/kontor-gui/gui/media_window.py | 2 +- python/kontor-gui/gui/meta_data_window.py | 2 +- python/kontor-schema/kontor_schema/admin.py | 2 +- python/kontor-schema/kontor_schema/base.py | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/python/kontor-gui/gui/main_window.py b/python/kontor-gui/gui/main_window.py index 6a2b591..a1921d7 100644 --- a/python/kontor-gui/gui/main_window.py +++ b/python/kontor-gui/gui/main_window.py @@ -168,7 +168,7 @@ class MainWindow(QMainWindow): self.mdi_area.removeSubWindow(meta_data) def remove_sub_window(self, name: str): - # self.log.info("remove subwindow %s", name) + self.log.info("remove subwindow %s", name) if name in self._subwindows: window = self._subwindows.pop(name) window.close() @@ -181,9 +181,9 @@ class MainWindow(QMainWindow): import_dlg = ImportKontorDialog(self) if import_dlg.exec(): print(f"import DB from file {import_dlg.file_name}") + self.kontor_db.import_db(import_dlg.file_name, False) else: print("do nothing for import") - pass def export_to_file(self): export_dlg = ExportKontorDialog(self, self.kontor_db) diff --git a/python/kontor-gui/gui/media_window.py b/python/kontor-gui/gui/media_window.py index 175dd07..1d9455f 100644 --- a/python/kontor-gui/gui/media_window.py +++ b/python/kontor-gui/gui/media_window.py @@ -33,7 +33,7 @@ class MediaWindow(QMdiSubWindow): def closeEvent(self, event): self.closed.emit() super().closeEvent(event) - self._main_window.remove_sub_window('comic') + self._main_window.remove_sub_window('media') def refresh(self): self.log.info("MediaWindow.refresh") diff --git a/python/kontor-gui/gui/meta_data_window.py b/python/kontor-gui/gui/meta_data_window.py index 77ce516..793fa16 100644 --- a/python/kontor-gui/gui/meta_data_window.py +++ b/python/kontor-gui/gui/meta_data_window.py @@ -33,7 +33,7 @@ class MetaDataWindow(QMdiSubWindow): def closeEvent(self, event): self.closed.emit() super().closeEvent(event) - self._main_window.remove_sub_window('comic') + self._main_window.remove_sub_window('meta_data') def refresh(self): # self.log.info("refresh") diff --git a/python/kontor-schema/kontor_schema/admin.py b/python/kontor-schema/kontor_schema/admin.py index b846d97..8dd33bd 100644 --- a/python/kontor-schema/kontor_schema/admin.py +++ b/python/kontor-schema/kontor_schema/admin.py @@ -35,7 +35,7 @@ class Token(Base, BaseMixin): name = Column(String(255)) last_used_date: Mapped[datetime] = mapped_column() enabled = Column(BIT(1)) - user_id = Column(String, ForeignKey("user.id"), nullable=False) + user_id = Column(String(255), ForeignKey("user.id"), nullable=False) user = relationship("User", back_populates="tokens") diff --git a/python/kontor-schema/kontor_schema/base.py b/python/kontor-schema/kontor_schema/base.py index dd4dbad..4a354e7 100644 --- a/python/kontor-schema/kontor_schema/base.py +++ b/python/kontor-schema/kontor_schema/base.py @@ -11,8 +11,8 @@ class Base(DeclarativeBase): class BaseMixin: - # id = Column(String, primary_key=True) - id: Mapped[str] = mapped_column(primary_key=True, default=uuid.uuid4()) + id = Column(String(255), primary_key=True, default=uuid.uuid4()) + # id: Mapped[str] = mapped_column(primary_key=True, default=uuid.uuid4()) # created_date = Column(DateTime) created_date: Mapped[datetime] = mapped_column(default=func.now()) # last_modified_date = Column(DateTime)