Merge pull request #1542 from pateljannat/zoom-refactor
feat: multiple zoom accounts and zoom attendance
This commit is contained in:
@@ -116,6 +116,7 @@ scheduler_events = {
|
||||
"lms.lms.doctype.lms_certificate_request.lms_certificate_request.schedule_evals",
|
||||
"lms.lms.api.update_course_statistics",
|
||||
"lms.lms.doctype.lms_certificate_request.lms_certificate_request.mark_eval_as_completed",
|
||||
"lms.lms.doctype.lms_live_class.lms_live_class.update_attendance",
|
||||
],
|
||||
"daily": [
|
||||
"lms.job.doctype.job_opportunity.job_opportunity.update_job_openings",
|
||||
|
||||
@@ -838,6 +838,14 @@ def delete_documents(doctype, documents):
|
||||
frappe.delete_doc(doctype, doc)
|
||||
|
||||
|
||||
@frappe.whitelist(allow_guest=True)
|
||||
def get_count(doctype, filters):
|
||||
return frappe.db.count(
|
||||
doctype,
|
||||
filters=filters,
|
||||
)
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_payment_gateway_details(payment_gateway):
|
||||
fields = []
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
"description",
|
||||
"column_break_hlqw",
|
||||
"instructors",
|
||||
"zoom_account",
|
||||
"section_break_rgfj",
|
||||
"medium",
|
||||
"category",
|
||||
@@ -354,6 +355,12 @@
|
||||
{
|
||||
"fieldname": "section_break_cssv",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "zoom_account",
|
||||
"fieldtype": "Link",
|
||||
"label": "Zoom Account",
|
||||
"options": "LMS Zoom Settings"
|
||||
}
|
||||
],
|
||||
"grid_page_length": 50,
|
||||
@@ -372,7 +379,7 @@
|
||||
"link_fieldname": "batch_name"
|
||||
}
|
||||
],
|
||||
"modified": "2025-05-21 13:30:28.904260",
|
||||
"modified": "2025-05-26 15:30:55.083507",
|
||||
"modified_by": "sayali@frappe.io",
|
||||
"module": "LMS",
|
||||
"name": "LMS Batch",
|
||||
|
||||
@@ -146,7 +146,15 @@ class LMSBatch(Document):
|
||||
|
||||
@frappe.whitelist()
|
||||
def create_live_class(
|
||||
batch_name, title, duration, date, time, timezone, auto_recording, description=None
|
||||
batch_name,
|
||||
zoom_account,
|
||||
title,
|
||||
duration,
|
||||
date,
|
||||
time,
|
||||
timezone,
|
||||
auto_recording,
|
||||
description=None,
|
||||
):
|
||||
frappe.only_for("Moderator")
|
||||
payload = {
|
||||
@@ -161,7 +169,7 @@ def create_live_class(
|
||||
"timezone": timezone,
|
||||
}
|
||||
headers = {
|
||||
"Authorization": "Bearer " + authenticate(),
|
||||
"Authorization": "Bearer " + authenticate(zoom_account),
|
||||
"content-type": "application/json",
|
||||
}
|
||||
response = requests.post(
|
||||
@@ -175,6 +183,8 @@ def create_live_class(
|
||||
"doctype": "LMS Live Class",
|
||||
"start_url": data.get("start_url"),
|
||||
"join_url": data.get("join_url"),
|
||||
"meeting_id": data.get("id"),
|
||||
"uuid": data.get("uuid"),
|
||||
"title": title,
|
||||
"host": frappe.session.user,
|
||||
"date": date,
|
||||
@@ -183,6 +193,7 @@ def create_live_class(
|
||||
"password": data.get("password"),
|
||||
"description": description,
|
||||
"auto_recording": auto_recording,
|
||||
"zoom_account": zoom_account,
|
||||
}
|
||||
)
|
||||
class_details = frappe.get_doc(payload)
|
||||
@@ -194,10 +205,10 @@ def create_live_class(
|
||||
)
|
||||
|
||||
|
||||
def authenticate():
|
||||
zoom = frappe.get_single("Zoom Settings")
|
||||
if not zoom.enable:
|
||||
frappe.throw(_("Please enable Zoom Settings to use this feature."))
|
||||
def authenticate(zoom_account):
|
||||
zoom = frappe.get_doc("LMS Zoom Settings", zoom_account)
|
||||
if not zoom.enabled:
|
||||
frappe.throw(_("Please enable the zoom account to use this feature."))
|
||||
|
||||
authenticate_url = f"https://zoom.us/oauth/token?grant_type=account_credentials&account_id={zoom.account_id}"
|
||||
|
||||
|
||||
@@ -9,21 +9,27 @@
|
||||
"field_order": [
|
||||
"title",
|
||||
"host",
|
||||
"zoom_account",
|
||||
"batch_name",
|
||||
"event",
|
||||
"column_break_astv",
|
||||
"description",
|
||||
"section_break_glxh",
|
||||
"date",
|
||||
"duration",
|
||||
"column_break_spvt",
|
||||
"time",
|
||||
"duration",
|
||||
"timezone",
|
||||
"section_break_yrpq",
|
||||
"section_break_glxh",
|
||||
"description",
|
||||
"column_break_spvt",
|
||||
"event",
|
||||
"auto_recording",
|
||||
"section_break_fhet",
|
||||
"meeting_id",
|
||||
"uuid",
|
||||
"column_break_aony",
|
||||
"attendees",
|
||||
"password",
|
||||
"section_break_yrpq",
|
||||
"start_url",
|
||||
"column_break_yokr",
|
||||
"auto_recording",
|
||||
"join_url"
|
||||
],
|
||||
"fields": [
|
||||
@@ -73,8 +79,7 @@
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_glxh",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Date and Time"
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_spvt",
|
||||
@@ -130,13 +135,50 @@
|
||||
"label": "Event",
|
||||
"options": "Event",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "zoom_account",
|
||||
"fieldtype": "Link",
|
||||
"label": "Zoom Account",
|
||||
"options": "LMS Zoom Settings",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "meeting_id",
|
||||
"fieldtype": "Data",
|
||||
"label": "Meeting ID"
|
||||
},
|
||||
{
|
||||
"fieldname": "attendees",
|
||||
"fieldtype": "Int",
|
||||
"label": "Attendees",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_fhet",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "uuid",
|
||||
"fieldtype": "Data",
|
||||
"label": "UUID"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_aony",
|
||||
"fieldtype": "Column Break"
|
||||
}
|
||||
],
|
||||
"grid_page_length": 50,
|
||||
"in_create": 1,
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2024-11-11 18:59:26.396111",
|
||||
"modified_by": "Administrator",
|
||||
"links": [
|
||||
{
|
||||
"link_doctype": "LMS Live Class Participant",
|
||||
"link_fieldname": "live_class"
|
||||
}
|
||||
],
|
||||
"modified": "2025-05-27 14:44:35.679712",
|
||||
"modified_by": "sayali@frappe.io",
|
||||
"module": "LMS",
|
||||
"name": "LMS Live Class",
|
||||
"owner": "Administrator",
|
||||
@@ -175,10 +217,11 @@
|
||||
"share": 1
|
||||
}
|
||||
],
|
||||
"row_format": "Dynamic",
|
||||
"show_title_field_in_link": 1,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"states": [],
|
||||
"title_field": "title",
|
||||
"track_changes": 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,13 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
import frappe
|
||||
import requests
|
||||
import json
|
||||
from frappe import _
|
||||
from frappe.model.document import Document
|
||||
from datetime import timedelta
|
||||
from frappe.utils import cint, get_datetime, format_date, nowdate, format_time
|
||||
from lms.lms.doctype.lms_batch.lms_batch import authenticate
|
||||
|
||||
|
||||
class LMSLiveClass(Document):
|
||||
@@ -102,3 +105,56 @@ def send_mail(live_class, student):
|
||||
args=args,
|
||||
header=[_(f"Class Reminder: {live_class.title}"), "orange"],
|
||||
)
|
||||
|
||||
|
||||
def update_attendance():
|
||||
past_live_classes = frappe.get_all(
|
||||
"LMS Live Class",
|
||||
{
|
||||
"uuid": ["is", "set"],
|
||||
"attendees": ["is", "not set"],
|
||||
},
|
||||
["name", "uuid", "zoom_account"],
|
||||
)
|
||||
|
||||
for live_class in past_live_classes:
|
||||
attendance_data = get_attendance(live_class)
|
||||
create_attendance(live_class, attendance_data)
|
||||
update_attendees_count(live_class, attendance_data)
|
||||
|
||||
|
||||
def get_attendance(live_class):
|
||||
headers = {
|
||||
"Authorization": "Bearer " + authenticate(live_class.zoom_account),
|
||||
"content-type": "application/json",
|
||||
}
|
||||
|
||||
encoded_uuid = requests.utils.quote(live_class.uuid, safe="")
|
||||
response = requests.get(
|
||||
f"https://api.zoom.us/v2/past_meetings/{encoded_uuid}/participants", headers=headers
|
||||
)
|
||||
|
||||
if response.status_code != 200:
|
||||
frappe.throw(
|
||||
_("Failed to fetch attendance data from Zoom for class {0}: {1}").format(
|
||||
live_class, response.text
|
||||
)
|
||||
)
|
||||
|
||||
data = response.json()
|
||||
return data.get("participants", [])
|
||||
|
||||
|
||||
def create_attendance(live_class, data):
|
||||
for participant in data:
|
||||
doc = frappe.new_doc("LMS Live Class Participant")
|
||||
doc.live_class = live_class.name
|
||||
doc.member = participant.get("user_email")
|
||||
doc.joined_at = participant.get("join_time")
|
||||
doc.left_at = participant.get("leave_time")
|
||||
doc.duration = participant.get("duration")
|
||||
doc.insert()
|
||||
|
||||
|
||||
def update_attendees_count(live_class, data):
|
||||
frappe.db.set_value("LMS Live Class", live_class.name, "attendees", len(data))
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// Copyright (c) 2025, Frappe and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
// frappe.ui.form.on("LMS Live Class Participant", {
|
||||
// refresh(frm) {
|
||||
|
||||
// },
|
||||
// });
|
||||
@@ -0,0 +1,116 @@
|
||||
{
|
||||
"actions": [],
|
||||
"allow_rename": 1,
|
||||
"creation": "2025-05-27 12:09:57.712221",
|
||||
"doctype": "DocType",
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"live_class",
|
||||
"joined_at",
|
||||
"column_break_dwbm",
|
||||
"duration",
|
||||
"left_at",
|
||||
"section_break_xczy",
|
||||
"member",
|
||||
"member_name",
|
||||
"column_break_bpjn",
|
||||
"member_image",
|
||||
"member_username"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "live_class",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 1,
|
||||
"label": "Live Class",
|
||||
"options": "LMS Live Class",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "member",
|
||||
"fieldtype": "Link",
|
||||
"in_standard_filter": 1,
|
||||
"label": "Member",
|
||||
"options": "User",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fetch_from": "member.full_name",
|
||||
"fieldname": "member_name",
|
||||
"fieldtype": "Data",
|
||||
"in_list_view": 1,
|
||||
"label": "Member Name"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_dwbm",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "duration",
|
||||
"fieldtype": "Int",
|
||||
"in_list_view": 1,
|
||||
"label": "Duration",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "joined_at",
|
||||
"fieldtype": "Datetime",
|
||||
"label": "Joined At",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "left_at",
|
||||
"fieldtype": "Datetime",
|
||||
"label": "Left At",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_xczy",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_bpjn",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fetch_from": "member.user_image",
|
||||
"fieldname": "member_image",
|
||||
"fieldtype": "Attach Image",
|
||||
"label": "Member Image"
|
||||
},
|
||||
{
|
||||
"fetch_from": "member.username",
|
||||
"fieldname": "member_username",
|
||||
"fieldtype": "Data",
|
||||
"label": "Member Username"
|
||||
}
|
||||
],
|
||||
"grid_page_length": 50,
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2025-05-27 22:32:24.196643",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Live Class Participant",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "System Manager",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"row_format": "Dynamic",
|
||||
"sort_field": "creation",
|
||||
"sort_order": "DESC",
|
||||
"states": [],
|
||||
"title_field": "member_name"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
# Copyright (c) 2025, Frappe and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
# import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
class LMSLiveClassParticipant(Document):
|
||||
pass
|
||||
@@ -0,0 +1,30 @@
|
||||
# Copyright (c) 2025, Frappe and Contributors
|
||||
# See license.txt
|
||||
|
||||
# import frappe
|
||||
from frappe.tests import IntegrationTestCase, UnitTestCase
|
||||
|
||||
|
||||
# On IntegrationTestCase, the doctype test records and all
|
||||
# link-field test record dependencies are recursively loaded
|
||||
# Use these module variables to add/remove to/from that list
|
||||
EXTRA_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"]
|
||||
IGNORE_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"]
|
||||
|
||||
|
||||
class UnitTestLMSLiveClassParticipant(UnitTestCase):
|
||||
"""
|
||||
Unit tests for LMSLiveClassParticipant.
|
||||
Use this class for testing individual functions and methods.
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class IntegrationTestLMSLiveClassParticipant(IntegrationTestCase):
|
||||
"""
|
||||
Integration tests for LMSLiveClassParticipant.
|
||||
Use this class for testing interactions between multiple components.
|
||||
"""
|
||||
|
||||
pass
|
||||
0
lms/lms/doctype/lms_zoom_settings/__init__.py
Normal file
0
lms/lms/doctype/lms_zoom_settings/__init__.py
Normal file
8
lms/lms/doctype/lms_zoom_settings/lms_zoom_settings.js
Normal file
8
lms/lms/doctype/lms_zoom_settings/lms_zoom_settings.js
Normal file
@@ -0,0 +1,8 @@
|
||||
// Copyright (c) 2025, Frappe and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
// frappe.ui.form.on("LMS Zoom Settings", {
|
||||
// refresh(frm) {
|
||||
|
||||
// },
|
||||
// });
|
||||
128
lms/lms/doctype/lms_zoom_settings/lms_zoom_settings.json
Normal file
128
lms/lms/doctype/lms_zoom_settings/lms_zoom_settings.json
Normal file
@@ -0,0 +1,128 @@
|
||||
{
|
||||
"actions": [],
|
||||
"allow_rename": 1,
|
||||
"autoname": "field:account_name",
|
||||
"creation": "2025-05-26 13:04:18.285735",
|
||||
"doctype": "DocType",
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"enabled",
|
||||
"section_break_xfow",
|
||||
"account_name",
|
||||
"member",
|
||||
"member_name",
|
||||
"column_break_fxxg",
|
||||
"account_id",
|
||||
"client_id",
|
||||
"client_secret"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "enabled",
|
||||
"fieldtype": "Check",
|
||||
"label": "Enabled"
|
||||
},
|
||||
{
|
||||
"fieldname": "account_id",
|
||||
"fieldtype": "Data",
|
||||
"in_list_view": 1,
|
||||
"label": "Account ID",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "client_id",
|
||||
"fieldtype": "Data",
|
||||
"label": "Client ID",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "client_secret",
|
||||
"fieldtype": "Password",
|
||||
"label": "Client Secret",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "member",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 1,
|
||||
"label": "Member",
|
||||
"options": "User",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fetch_from": "member.full_name",
|
||||
"fieldname": "member_name",
|
||||
"fieldtype": "Data",
|
||||
"label": "Member Name"
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_xfow",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "account_name",
|
||||
"fieldtype": "Data",
|
||||
"label": "Account Name",
|
||||
"reqd": 1,
|
||||
"unique": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_fxxg",
|
||||
"fieldtype": "Column Break"
|
||||
}
|
||||
],
|
||||
"grid_page_length": 50,
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2025-05-26 18:09:09.392368",
|
||||
"modified_by": "sayali@frappe.io",
|
||||
"module": "LMS",
|
||||
"name": "LMS Zoom Settings",
|
||||
"naming_rule": "By fieldname",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "System Manager",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Moderator",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"if_owner": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Batch Evaluator",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"row_format": "Dynamic",
|
||||
"sort_field": "creation",
|
||||
"sort_order": "DESC",
|
||||
"states": []
|
||||
}
|
||||
9
lms/lms/doctype/lms_zoom_settings/lms_zoom_settings.py
Normal file
9
lms/lms/doctype/lms_zoom_settings/lms_zoom_settings.py
Normal file
@@ -0,0 +1,9 @@
|
||||
# Copyright (c) 2025, Frappe and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
# import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
class LMSZoomSettings(Document):
|
||||
pass
|
||||
30
lms/lms/doctype/lms_zoom_settings/test_lms_zoom_settings.py
Normal file
30
lms/lms/doctype/lms_zoom_settings/test_lms_zoom_settings.py
Normal file
@@ -0,0 +1,30 @@
|
||||
# Copyright (c) 2025, Frappe and Contributors
|
||||
# See license.txt
|
||||
|
||||
# import frappe
|
||||
from frappe.tests import IntegrationTestCase, UnitTestCase
|
||||
|
||||
|
||||
# On IntegrationTestCase, the doctype test records and all
|
||||
# link-field test record dependencies are recursively loaded
|
||||
# Use these module variables to add/remove to/from that list
|
||||
EXTRA_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"]
|
||||
IGNORE_TEST_RECORD_DEPENDENCIES = [] # eg. ["User"]
|
||||
|
||||
|
||||
class UnitTestLMSZoomSettings(UnitTestCase):
|
||||
"""
|
||||
Unit tests for LMSZoomSettings.
|
||||
Use this class for testing individual functions and methods.
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class IntegrationTestLMSZoomSettings(IntegrationTestCase):
|
||||
"""
|
||||
Integration tests for LMSZoomSettings.
|
||||
Use this class for testing interactions between multiple components.
|
||||
"""
|
||||
|
||||
pass
|
||||
@@ -1391,6 +1391,7 @@ def get_batch_details(batch):
|
||||
"certification",
|
||||
"timezone",
|
||||
"category",
|
||||
"zoom_account",
|
||||
],
|
||||
as_dict=True,
|
||||
)
|
||||
|
||||
@@ -103,4 +103,7 @@ lms.patches.v2_0.delete_old_enrollment_doctypes
|
||||
lms.patches.v2_0.delete_unused_custom_fields
|
||||
lms.patches.v2_0.update_certificate_request_status
|
||||
lms.patches.v2_0.update_job_city_and_country
|
||||
lms.patches.v2_0.update_course_evaluator_data
|
||||
lms.patches.v2_0.update_course_evaluator_data
|
||||
lms.patches.v2_0.move_zoom_settings #20-05-2025
|
||||
lms.patches.v2_0.link_zoom_account_to_live_class
|
||||
lms.patches.v2_0.link_zoom_account_to_batch
|
||||
11
lms/patches/v2_0/link_zoom_account_to_batch.py
Normal file
11
lms/patches/v2_0/link_zoom_account_to_batch.py
Normal file
@@ -0,0 +1,11 @@
|
||||
import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
live_classes = frappe.get_all("LMS Live Class", ["name", "batch_name"])
|
||||
zoom_account = frappe.get_all("LMS Zoom Settings", pluck="name")
|
||||
zoom_account = zoom_account[0] if zoom_account else None
|
||||
|
||||
if zoom_account:
|
||||
for live_class in live_classes:
|
||||
frappe.db.set_value("LMS Batch", live_class.batch_name, "zoom_account", zoom_account)
|
||||
16
lms/patches/v2_0/link_zoom_account_to_live_class.py
Normal file
16
lms/patches/v2_0/link_zoom_account_to_live_class.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
live_classes = frappe.get_all("LMS Live Class", pluck="name")
|
||||
zoom_account = frappe.get_all("LMS Zoom Settings", pluck="name")
|
||||
zoom_account = zoom_account[0] if zoom_account else None
|
||||
|
||||
if zoom_account:
|
||||
for live_class in live_classes:
|
||||
frappe.db.set_value(
|
||||
"LMS Live Class",
|
||||
live_class,
|
||||
"zoom_account",
|
||||
zoom_account,
|
||||
)
|
||||
27
lms/patches/v2_0/move_zoom_settings.py
Normal file
27
lms/patches/v2_0/move_zoom_settings.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
create_settings()
|
||||
|
||||
|
||||
def create_settings():
|
||||
current_settings = frappe.get_single("Zoom Settings")
|
||||
member = current_settings.owner
|
||||
member_name = frappe.get_value("User", member, "full_name")
|
||||
|
||||
if not frappe.db.exists(
|
||||
"LMS Zoom Settings",
|
||||
{
|
||||
"account_name": member_name,
|
||||
},
|
||||
):
|
||||
new_settings = frappe.new_doc("LMS Zoom Settings")
|
||||
new_settings.enabled = current_settings.enable
|
||||
new_settings.account_name = member_name
|
||||
new_settings.member = member
|
||||
new_settings.member_name = member_name
|
||||
new_settings.account_id = current_settings.account_id
|
||||
new_settings.client_id = current_settings.client_id
|
||||
new_settings.client_secret = current_settings.client_secret
|
||||
new_settings.insert()
|
||||
Reference in New Issue
Block a user