adjust citysite table name to activesites

This commit is contained in:
Alberto-Audrix committed 2026-09-11 15:51:29 +07:00
1 parent fb0f996776
commit 64b37b6b6d
27 files changed
+382 -221

No files matched your search

+14 -6
View File
@@ -1,4 +1,4 @@
"""Push close decisions from pusat to city dashboard-cpsp."""
"""Push close decisions from pusat to farm-location dashboard-cpsp."""
from __future__ import annotations
@@ -18,12 +18,17 @@ class SiteClosePushError(Exception):
def push_close_decision(cycle: Cycle, *, approved: bool) -> None:
city = cycle.city_site
if not city or not city.api_base_url or not city.api_key or not cycle.source_cycle_id:
logger.info("No city channel configured for cycle %s; skip push", cycle.pk)
active_site = cycle.active_site
if (
not active_site
or not active_site.api_base_url
or not active_site.api_key
or not cycle.source_cycle_id
):
logger.info("No active-site channel configured for cycle %s; skip push", cycle.pk)
return
base = city.api_base_url.rstrip("/")
base = active_site.api_base_url.rstrip("/")
url = f"{base}/cycles/{cycle.source_cycle_id}/apply-close-decision/"
payload = {"decision": "approve" if approved else "reject"}
if approved:
@@ -35,7 +40,10 @@ def push_close_decision(cycle: Cycle, *, approved: bool) -> None:
response = httpx.post(
url,
json=payload,
headers={"X-API-Key": city.api_key, "Content-Type": "application/json"},
headers={
"X-API-Key": active_site.api_key,
"Content-Type": "application/json",
},
timeout=30.0,
)
if response.status_code >= 400: