From 9a9509530de0991d42164fe8f0bd61c3a0fc976f Mon Sep 17 00:00:00 2001 From: AKHIL S Date: Sun, 8 Oct 2023 21:15:04 +0530 Subject: [PATCH] Create create.py --- python-frappe/media/create.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 python-frappe/media/create.py diff --git a/python-frappe/media/create.py b/python-frappe/media/create.py new file mode 100644 index 0000000..141cfb0 --- /dev/null +++ b/python-frappe/media/create.py @@ -0,0 +1,24 @@ +# link_bundler/link_bundler/page/create/create.py + +import frappe + +def get_context(context): + if frappe.session.user == "Guest": + frappe.local.flags.redirect_location = "/login" # Redirect guest users to the login page + raise frappe.Redirect + +def create_bundle(): + bundle = frappe.new_doc("LinkBundle") + bundle.creator = frappe.session.user + bundle.save() + + return bundle + +@frappe.whitelist() +def add_link(link_url, bundle_name): + bundle = frappe.get_doc("LinkBundle", bundle_name) + link_item = bundle.append("links", {}) + link_item.link_url = link_url + bundle.save() + + return link_item.name