Skip to content

Commit

Permalink
hooks. add to meta_data if material is ordered
Browse files Browse the repository at this point in the history
  • Loading branch information
diversen7 committed Dec 19, 2024
1 parent ca60247 commit 8146534
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions example-config-aarhus/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import json
from stadsarkiv_client.database.crud_default import database_url
from stadsarkiv_client.database.crud import CRUD
from stadsarkiv_client.database import crud_orders
from stadsarkiv_client.database.utils import DatabaseConnection
from stadsarkiv_client.database.cache import DatabaseCache
from stadsarkiv_client.core import csv_utils
Expand Down Expand Up @@ -127,6 +128,14 @@ async def after_get_record(self, record: dict, meta_data: dict) -> tuple:
if record.get("summary"):
meta_data["title"] = f"[{record['summary']}]"

# check if record is order by user
me = await api.me_get(self.request)
meta_data["has_active_order"] = False
if me:
user_id = me["id"]
has_active_order = await crud_orders.has_active_order(user_id=user_id, record_id=meta_data["id"])
meta_data["has_active_order"] = has_active_order

return record, meta_data

async def after_get_record_and_types(self, record: dict, record_and_types: dict) -> tuple:
Expand Down

0 comments on commit 8146534

Please sign in to comment.