Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions frappe_crm_xt/api/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,12 @@ def get_latest_activity(name: str) -> dict | None:
return None

doctype = _resolve_reference_doctype(name)

if not doctype:
return None

frappe.has_permission(doctype, "read", doc=name, throw=True)

# Cheap pre-flight: query the most-recent single row from each source
# (4 indexed lookups), pick the winner, then fully hydrate ONLY that one.
# Avoids the previous "fetch all notes/tasks + N+1 attachment loads".
Expand Down
7 changes: 7 additions & 0 deletions frappe_crm_xt/api/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ def search_emails(txt: str = ""):
@frappe.whitelist()
def get_doc_events(doctype: str, docname: str | int):
"""Fetch events linked to a document with their participants and notifications."""

if doctype not in ["CRM Deal", "CRM Lead"]:
return []

frappe.has_permission(doctype, "read", doc=docname, throw=True)

event = frappe.qb.DocType("Event")
event_participant = frappe.qb.DocType("Event Participants")

Expand Down Expand Up @@ -80,6 +86,7 @@ def get_doc_events(doctype: str, docname: str | int):

event_names = [e.name for e in events]

# TODO: NEED TO CHECK HOW IT WORKS
participants = frappe.get_all(
"Event Participants",
filters={"parent": ["in", event_names], "parenttype": "Event"},
Expand Down
Loading