generated from dopt-python/py311
iteration for new data model
This commit is contained in:
+43
-16
@@ -19,9 +19,48 @@ from PySide6.QtCore import QDate, Qt
|
||||
|
||||
from wce_crm import constants, db
|
||||
from wce_crm.backend import backend
|
||||
from wce_crm.types import NewEntityIds, RecordingType
|
||||
|
||||
# %%
|
||||
int("test")
|
||||
raw_ent_ids = NewEntityIds()
|
||||
db_ent_ids = NewEntityIds(un_id=3, an_id=2)
|
||||
|
||||
print(f"{raw_ent_ids=}\n{db_ent_ids=}")
|
||||
print(f"{raw_ent_ids.empty()=}")
|
||||
print(f"{raw_ent_ids.valid()=}")
|
||||
# %%
|
||||
raw_ent_ids.update(db_ent_ids)
|
||||
print(f"{raw_ent_ids=}")
|
||||
db_ent_ids = NewEntityIds(un_id=None, an_id=2, link_id=1)
|
||||
raw_ent_ids.update(db_ent_ids)
|
||||
print(f"{raw_ent_ids=}")
|
||||
print(f"{raw_ent_ids.empty()=}")
|
||||
print(f"{raw_ent_ids.valid()=}")
|
||||
raw_ent_ids.update(NewEntityIds())
|
||||
print(f"{raw_ent_ids=}")
|
||||
print(f"{raw_ent_ids.empty()=}")
|
||||
print(f"{raw_ent_ids.valid()=}")
|
||||
|
||||
# %%
|
||||
raw_ent_ids.update(NewEntityIds(un_id=None, pers_id=2))
|
||||
print(f"{raw_ent_ids=}")
|
||||
print(f"{raw_ent_ids.empty()=}")
|
||||
print(f"{raw_ent_ids.empty(RecordingType.COMPANY)=}")
|
||||
print(f"{raw_ent_ids.empty(RecordingType.PERSON)=}")
|
||||
print(f"{raw_ent_ids.valid(RecordingType.COMPANY)=}")
|
||||
print(f"{raw_ent_ids.valid(RecordingType.PERSON)=}")
|
||||
raw_ent_ids.update(NewEntityIds(un_id=None, an_id=2, link_id=3, pers_id=2))
|
||||
print(f"{raw_ent_ids=}")
|
||||
print(f"{raw_ent_ids.empty(RecordingType.COMPANY)=}")
|
||||
print(f"{raw_ent_ids.empty(RecordingType.PERSON)=}")
|
||||
print(f"{raw_ent_ids.valid(RecordingType.COMPANY)=}")
|
||||
print(f"{raw_ent_ids.valid(RecordingType.PERSON)=}")
|
||||
raw_ent_ids.update(NewEntityIds(un_id=2, pers_id=None, an_id=2, link_id=3))
|
||||
print(f"{raw_ent_ids=}")
|
||||
print(f"{raw_ent_ids.empty(RecordingType.COMPANY)=}")
|
||||
print(f"{raw_ent_ids.empty(RecordingType.PERSON)=}")
|
||||
print(f"{raw_ent_ids.valid(RecordingType.COMPANY)=}")
|
||||
print(f"{raw_ent_ids.valid(RecordingType.PERSON)=}")
|
||||
|
||||
# %%
|
||||
db_path = constants.Config.DB_PATH_MAIN
|
||||
@@ -29,22 +68,10 @@ crm_path = constants.Config.DB_PATH_CRM
|
||||
engine = sql.create_engine(f"sqlite:///{str(db_path)}")
|
||||
engine_crm = sql.create_engine(f"sqlite:///{str(crm_path)}")
|
||||
# %%
|
||||
stmt = sql.select(
|
||||
db.grunderfassung.c.erfassung_id,
|
||||
db.grunderfassung.c.Partnersuche__un_suche,
|
||||
)
|
||||
|
||||
with engine.connect() as conn:
|
||||
res = conn.execute(stmt)
|
||||
|
||||
|
||||
for r in res:
|
||||
print(r)
|
||||
# %%
|
||||
|
||||
|
||||
# %%
|
||||
backend._main_page_get_company_list()
|
||||
backend._main_page_get_company_list() # type: ignore
|
||||
|
||||
|
||||
# %%
|
||||
@@ -218,12 +245,12 @@ class FlatBaseModel(BaseModel):
|
||||
|
||||
return final_nested_data
|
||||
|
||||
def to_db(self) -> Dict[str, Any]:
|
||||
def to_db(self) -> dict[str, Any]:
|
||||
"""Ausgang für die DB: Flach, Listen sind JSON-Strings."""
|
||||
nested = super().model_dump()
|
||||
return self.__flatten_dict(nested, serialize_lists=True)
|
||||
|
||||
def to_gui(self) -> Dict[str, Any]:
|
||||
def to_gui(self) -> dict[str, Any]:
|
||||
"""Ausgang für die GUI: Flach, aber Listen bleiben Python-Listen."""
|
||||
nested = super().model_dump()
|
||||
return self.__flatten_dict(nested, serialize_lists=False)
|
||||
|
||||
Reference in New Issue
Block a user