From 19118ba45f3a16298405bf061bf0d098b18d813d Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Fri, 7 Aug 2020 20:55:07 +0530 Subject: [PATCH] feat: add API to add participants to event --- frappe/desk/doctype/event/event.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/frappe/desk/doctype/event/event.py b/frappe/desk/doctype/event/event.py index 45dc5d86c7..54905bed6a 100644 --- a/frappe/desk/doctype/event/event.py +++ b/frappe/desk/doctype/event/event.py @@ -82,6 +82,27 @@ class Event(Document): communication.add_link(participant.reference_doctype, participant.reference_docname) communication.save(ignore_permissions=True) + def add_participant(self, doctype, docname): + """Add a single participant to event participants + + Args: + doctype (string): Reference Doctype + docname (string): Reference Docname + """ + self.append("event_participants", { + "reference_doctype": doctype, + "reference_docname": docname, + }) + + def add_participants(self, participants): + """Add participant entry + + Args: + participants ([Array]): Array of a dict with doctype and docname + """ + for participant in participants: + self.add_participant(participant["doctype"], participant["docname"]) + @frappe.whitelist() def delete_communication(event, reference_doctype, reference_docname): deleted_participant = frappe.get_doc(reference_doctype, reference_docname)