Increase security and reformat

This commit is contained in:
2026-03-07 20:52:13 +00:00
parent 10588a18b9
commit bca4d6898f
144 changed files with 6735 additions and 3960 deletions

View File

@@ -972,7 +972,9 @@ def _history_points(conversation, field_name, density="medium"):
for row in rows:
source_ts = int(row.get("source_event_ts") or 0)
if source_ts > 0:
x_value = datetime.fromtimestamp(source_ts / 1000, tz=timezone.utc).isoformat()
x_value = datetime.fromtimestamp(
source_ts / 1000, tz=timezone.utc
).isoformat()
else:
x_value = row["computed_at"].isoformat()
raw_points.append(
@@ -995,11 +997,9 @@ def _metric_supports_history(metric_slug, metric_spec):
def _all_graph_payload(conversation, density="medium"):
graphs = []
for spec in INSIGHT_GRAPH_SPECS:
raw_count = (
conversation.metric_snapshots.exclude(
**{f"{spec['field']}__isnull": True}
).count()
)
raw_count = conversation.metric_snapshots.exclude(
**{f"{spec['field']}__isnull": True}
).count()
points = _history_points(conversation, spec["field"], density=density)
graphs.append(
{
@@ -3557,13 +3557,13 @@ class AIWorkspaceContactsWidget(LoginRequiredMixin, View):
{
"person": person,
"message_count": message_qs.count(),
"last_text": (last_message.text or "")[:120]
if last_message
else "",
"last_text": (
(last_message.text or "")[:120] if last_message else ""
),
"last_ts": last_message.ts if last_message else None,
"last_ts_label": _format_unix_ms(last_message.ts)
if last_message
else "",
"last_ts_label": (
_format_unix_ms(last_message.ts) if last_message else ""
),
}
)
rows.sort(key=lambda row: row["last_ts"] or 0, reverse=True)
@@ -4355,7 +4355,7 @@ class AIWorkspaceQueueDraft(LoginRequiredMixin, View):
return _render_send_status(
request,
False,
"No enabled manipulation found for this recipient. Queue entry not created.",
"No enabled manipulation found for this recipient. Approvals queue entry not created.",
"warning",
)
@@ -5099,7 +5099,7 @@ class AIWorkspaceEngageShare(LoginRequiredMixin, View):
request,
person,
plan,
notice_message="No enabled manipulation found for this recipient. Queue entry not created.",
notice_message="No enabled manipulation found for this recipient. Approvals queue entry not created.",
notice_level="warning",
engage_preview=engage_preview,
engage_form=engage_form,