Files
lms/community/lms/api.py
Anand Chitipothu f1508033a3 feat: implemented autosave for sections
Now the changes made to the code in each section will be autosaved and loaded
back on next page load.
2021-04-07 01:40:13 +05:30

24 lines
536 B
Python

"""API methods for the LMS.
"""
import frappe
@frappe.whitelist()
def autosave_section(section, code):
"""Saves the code edited in one of the sections.
"""
doc = frappe.get_doc(
doctype="Code Revision",
section=section,
code=code,
author=frappe.session.user)
doc.insert()
return {"name": doc.name}
@frappe.whitelist()
def get_section(name):
"""Saves the code edited in one of the sections.
"""
doc = frappe.get_doc("LMS Section", name)
return doc and doc.as_dict()