frontend admin refakctorálás
This commit is contained in:
@@ -707,17 +707,22 @@ async def get_organization_details(
|
||||
|
||||
# 2c. P0 ADD-ON: Telephelyek (branches) lekérése
|
||||
from app.models.marketplace.organization import Branch # noqa: E402
|
||||
branches_stmt = select(Branch).where(
|
||||
Branch.organization_id == org_id,
|
||||
Branch.is_deleted == False,
|
||||
).order_by(Branch.name)
|
||||
branches_stmt = (
|
||||
select(Branch)
|
||||
.options(selectinload(Branch.address))
|
||||
.where(
|
||||
Branch.organization_id == org_id,
|
||||
Branch.is_deleted == False,
|
||||
)
|
||||
.order_by(Branch.name)
|
||||
)
|
||||
branches_result = await db.execute(branches_stmt)
|
||||
branch_rows = branches_result.scalars().all()
|
||||
branches_list = [
|
||||
BranchBrief(
|
||||
id=str(b.id),
|
||||
name=b.name,
|
||||
city=b.city,
|
||||
city=b.address.city if b.address else None,
|
||||
is_active=(b.status == "active") if b.status else True,
|
||||
)
|
||||
for b in branch_rows
|
||||
@@ -1319,6 +1324,10 @@ async def update_organization(
|
||||
# ── Primary address via AddressManager ──
|
||||
address_detail: Optional[AddressIn] = raw_data.pop("address_detail", None)
|
||||
if address_detail:
|
||||
# P0 BUGFIX: model_dump() converts nested Pydantic models to dicts;
|
||||
# re-wrap into AddressIn before passing to AddressManager
|
||||
if isinstance(address_detail, dict):
|
||||
address_detail = AddressIn(**address_detail)
|
||||
org.address_id = await AddressManager.create_or_update(
|
||||
db, org.address_id, address_detail
|
||||
)
|
||||
@@ -1326,6 +1335,8 @@ async def update_organization(
|
||||
# ── Billing address via AddressManager ──
|
||||
billing_address_detail: Optional[AddressIn] = raw_data.pop("billing_address_detail", None)
|
||||
if billing_address_detail:
|
||||
if isinstance(billing_address_detail, dict):
|
||||
billing_address_detail = AddressIn(**billing_address_detail)
|
||||
org.billing_address_id = await AddressManager.create_or_update(
|
||||
db, org.billing_address_id, billing_address_detail
|
||||
)
|
||||
@@ -1333,6 +1344,8 @@ async def update_organization(
|
||||
# ── Notification address via AddressManager ──
|
||||
notification_address_detail: Optional[AddressIn] = raw_data.pop("notification_address_detail", None)
|
||||
if notification_address_detail:
|
||||
if isinstance(notification_address_detail, dict):
|
||||
notification_address_detail = AddressIn(**notification_address_detail)
|
||||
org.notification_address_id = await AddressManager.create_or_update(
|
||||
db, org.notification_address_id, notification_address_detail
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user