feat: google calendar integration
This commit is contained in:
@@ -304,10 +304,24 @@ def get_unsplash_photos(keyword=None):
|
||||
def get_evaluator_details(evaluator):
|
||||
frappe.only_for("Batch Evaluator")
|
||||
|
||||
if not frappe.db.exists("Google Calendar", {"user": evaluator}):
|
||||
calendar = frappe.new_doc("Google Calendar")
|
||||
calendar.update({"user": evaluator, "calendar_name": evaluator})
|
||||
calendar.insert()
|
||||
else:
|
||||
calendar = frappe.db.get_value(
|
||||
"Google Calendar", {"user": evaluator}, ["name", "authorization_code"], as_dict=1
|
||||
)
|
||||
|
||||
if frappe.db.exists("Course Evaluator", {"evaluator": evaluator}):
|
||||
return frappe.get_doc("Course Evaluator", evaluator, as_dict=1)
|
||||
doc = frappe.get_doc("Course Evaluator", evaluator, as_dict=1)
|
||||
else:
|
||||
doc = frappe.new_doc("Course Evaluator")
|
||||
doc.evaluator = evaluator
|
||||
doc.insert()
|
||||
return doc.as_dict()
|
||||
|
||||
return {
|
||||
"slots": doc.as_dict(),
|
||||
"calendar": calendar.name,
|
||||
"is_authorised": calendar.authorization_code,
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
"force_profile_completion",
|
||||
"is_onboarding_complete",
|
||||
"column_break_zdel",
|
||||
"unsplash_access_key",
|
||||
"livecode_url",
|
||||
"course_settings_section",
|
||||
"search_placeholder",
|
||||
@@ -96,6 +97,7 @@
|
||||
"default": "0",
|
||||
"fieldname": "force_profile_completion",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 1,
|
||||
"label": "Force users to complete their Profile"
|
||||
},
|
||||
{
|
||||
@@ -348,12 +350,17 @@
|
||||
"fieldname": "show_day_view",
|
||||
"fieldtype": "Check",
|
||||
"label": "Show Day View in Timetable"
|
||||
},
|
||||
{
|
||||
"fieldname": "unsplash_access_key",
|
||||
"fieldtype": "Data",
|
||||
"label": "Unsplash Access Key"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"issingle": 1,
|
||||
"links": [],
|
||||
"modified": "2023-12-12 10:32:13.638368",
|
||||
"modified": "2024-04-16 12:18:14.670978",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Settings",
|
||||
|
||||
@@ -23,8 +23,9 @@ def get_random(params=None):
|
||||
|
||||
|
||||
def make_unsplash_request(path):
|
||||
if not "unsplash_access_key" in frappe.conf:
|
||||
frappe.throw("Please set unsplash_access_key in site_config.json")
|
||||
unsplash_access_key = frappe.db.get_single_value("LMS Settings", "unsplash_access_key")
|
||||
if not unsplash_access_key:
|
||||
return
|
||||
|
||||
import requests
|
||||
|
||||
@@ -34,7 +35,7 @@ def make_unsplash_request(path):
|
||||
url,
|
||||
headers={
|
||||
"Accept-Version": "v1",
|
||||
"Authorization": f"Client-ID {frappe.conf.unsplash_access_key}",
|
||||
"Authorization": f"Client-ID {unsplash_access_key}",
|
||||
},
|
||||
)
|
||||
res.raise_for_status()
|
||||
|
||||
Reference in New Issue
Block a user