feat: live class

This commit is contained in:
Jannat Patel
2023-02-28 09:19:37 +05:30
parent 3ee592a989
commit 34870b4625
9 changed files with 153 additions and 1 deletions

View File

@@ -5,6 +5,9 @@ import frappe
from frappe.model.document import Document from frappe.model.document import Document
from frappe import _ from frappe import _
from frappe.utils import cint from frappe.utils import cint
import requests
import urllib
from requests.auth import HTTPBasicAuth
class LMSClass(Document): class LMSClass(Document):
@@ -85,3 +88,22 @@ def update_course(class_name, course, value):
else: else:
frappe.db.delete("Class Course", {"parent": class_name, "course": course}) frappe.db.delete("Class Course", {"parent": class_name, "course": course})
return True return True
@frappe.whitelist()
def create_live_class(class_name):
authenticate()
def authenticate():
zoom = frappe.get_single("Zoom Settings")
if not zoom.enable:
frappe.throw(_("Please enable Zoom Settings to use this feature."))
authenticate_url = "https://zoom.us/oauth/token?grant_type=client_credentials"
print(authenticate_url)
breakpoint
r = requests.get(
authenticate_url, auth=HTTPBasicAuth(zoom.client_id, zoom.client_secret)
)
return r

View File

@@ -0,0 +1,9 @@
# Copyright (c) 2023, Frappe and Contributors
# See license.txt
# import frappe
from frappe.tests.utils import FrappeTestCase
class TestZoomSettings(FrappeTestCase):
pass

View File

@@ -0,0 +1,8 @@
// Copyright (c) 2023, Frappe and contributors
// For license information, please see license.txt
// frappe.ui.form.on("Zoom Settings", {
// refresh(frm) {
// },
// });

View File

@@ -0,0 +1,65 @@
{
"actions": [],
"creation": "2023-02-27 14:30:28.696814",
"default_view": "List",
"doctype": "DocType",
"engine": "InnoDB",
"field_order": [
"enable",
"sb_00",
"client_id",
"client_secret"
],
"fields": [
{
"default": "0",
"fieldname": "enable",
"fieldtype": "Check",
"label": "Enable"
},
{
"depends_on": "enable",
"fieldname": "sb_00",
"fieldtype": "Section Break",
"label": "OAuth Client ID"
},
{
"description": "The Client ID obtained from the Google Cloud Console under <a href=\"https://console.cloud.google.com/apis/credentials\">\n\"APIs &amp; Services\" &gt; \"Credentials\"\n</a>",
"fieldname": "client_id",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Client ID",
"mandatory_depends_on": "google_drive_picker_enabled"
},
{
"fieldname": "client_secret",
"fieldtype": "Password",
"in_list_view": 1,
"label": "Client Secret"
}
],
"issingle": 1,
"links": [],
"modified": "2023-02-27 14:30:28.696814",
"modified_by": "Administrator",
"module": "LMS",
"name": "Zoom Settings",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"print": 1,
"read": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"quick_entry": 1,
"sort_field": "modified",
"sort_order": "ASC",
"states": [],
"track_changes": 1
}

View File

@@ -0,0 +1,9 @@
# Copyright (c) 2023, Frappe and contributors
# For license information, please see license.txt
# import frappe
from frappe.model.document import Document
class ZoomSettings(Document):
pass

View File

@@ -114,7 +114,7 @@ def sanitize_html(html, macro):
any broken tags. This makes sures that all those things are fixed any broken tags. This makes sures that all those things are fixed
before passing to the etree parser. before passing to the etree parser.
""" """
soup = BeautifulSoup(html, features="lxml") soup = BeautifulSoup(html, features="html5lib")
nodes = soup.body.children nodes = soup.body.children
classname = "" classname = ""
if macro == "YouTubeVideo": if macro == "YouTubeVideo":

View File

@@ -74,6 +74,12 @@
</a> </a>
</li> </li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#live-class">
{{ _("Live Class") }}
</a>
</li>
</ul> </ul>
<div class="border-bottom mb-4"></div> <div class="border-bottom mb-4"></div>
@@ -87,6 +93,10 @@
{{ StudentsSection(class_info, class_students) }} {{ StudentsSection(class_info, class_students) }}
</div> </div>
<div class="tab-pane" id="live-class" role="tabpanel" aria-labelledby="live-class">
{{ LiveClassSection(class_info) }}
</div>
</div> </div>
</div> </div>
{% endmacro %} {% endmacro %}
@@ -176,3 +186,14 @@
</form> </form>
</div> </div>
{% endmacro %} {% endmacro %}
{% macro LiveClassSection(class_info) %}
<div>
{% if is_moderator %}
<button class="btn btn-secondary btn-sm" id="create-live-class">
{{ _("Create a Live Class") }}
</button>
{% endif %}
</div>
{% endmacro %}

View File

@@ -10,6 +10,11 @@ frappe.ready(() => {
$(".class-course").click((e) => { $(".class-course").click((e) => {
update_course(e); update_course(e);
}); });
$("#create-live-class").click((e) => {
console.log("call");
create_live_class(e);
});
}); });
const submit_student = (e) => { const submit_student = (e) => {
@@ -68,3 +73,16 @@ const update_course = (e) => {
}, },
}); });
}; };
const create_live_class = (e) => {
console.log("call");
frappe.call({
method: "lms.lms.doctype.lms_class.lms_class.create_live_class",
args: {
class_name: $(".class-details").data("class"),
},
callback: (data) => {
console.log(data);
},
});
};