Add owner chip for unpaid submissions

This commit is contained in:
Simon Gruber
2026-05-05 19:34:41 +02:00
parent d037f1ded0
commit 24fd13340e
4 changed files with 16 additions and 2 deletions
+6 -1
View File
@@ -130,7 +130,7 @@ def row_to_my_order(row: sqlite3.Row) -> dict:
except json.JSONDecodeError:
submission_choices = {}
return {
result = {
"id": row["id"],
"title": row["title"],
"description": row["description"],
@@ -145,3 +145,8 @@ def row_to_my_order(row: sqlite3.Row) -> dict:
"paid": bool(row["paid"]) if row["paid"] is not None else False,
},
}
if "has_unpaid_submissions" in row.keys() and row["has_unpaid_submissions"] is not None:
result["has_unpaid_submissions"] = bool(row["has_unpaid_submissions"])
return result
+6 -1
View File
@@ -674,7 +674,12 @@ def get_my_orders(
uot.submission_token,
s.choices_json,
s.accepted,
s.paid
s.paid,
CASE
WHEN uot.admin_token IS NOT NULL THEN
(SELECT COUNT(*) FROM submissions s2 WHERE s2.group_order_id = go.id AND s2.accepted = 1 AND (s2.paid IS NULL OR s2.paid = 0))
ELSE 0
END AS has_unpaid_submissions
FROM user_order_tokens uot
JOIN group_orders go ON go.id = uot.group_order_id
LEFT JOIN submissions s ON s.submission_token = uot.submission_token
@@ -104,6 +104,9 @@ export default function HomeOrdersTable({
<Space size={8} align="center">
<Text strong>{item.title || item.id}</Text>
{item.is_owner ? <Tag color="geekblue">Owner</Tag> : null}
{item.is_owner && item.has_unpaid_submissions ? (
<Tag color="volcano">Open payments</Tag>
) : null}
{state === "paid" ? <Tag color="green">Paid</Tag> : null}
{state === "unpaid" ? (
<Tag color="volcano">Unpaid</Tag>
+1
View File
@@ -73,6 +73,7 @@ export type Order = OrderBase & {
is_owner: boolean;
is_participant: boolean;
};
has_unpaid_submissions?: boolean;
};
export type OrderAdminView = OrderBase & {