Merge pull request #477 from pateljannat/evaluation-event

This commit is contained in:
Jannat Patel
2023-02-17 11:01:54 +05:30
committed by GitHub
7 changed files with 139 additions and 19 deletions

View File

@@ -3,7 +3,7 @@
frappe.ui.form.on("LMS Certificate Evaluation", {
refresh: function (frm) {
if (frm.doc.status == "Pass") {
if (!frm.is_new() && frm.doc.status == "Pass") {
frm.add_custom_button(__("Create LMS Certificate"), () => {
frappe.model.open_mapped_doc({
method: "lms.lms.doctype.lms_certificate_evaluation.lms_certificate_evaluation.create_lms_certificate",

View File

@@ -3,12 +3,17 @@
frappe.ui.form.on("LMS Certificate Request", {
refresh: function (frm) {
frm.add_custom_button(__("Create LMS Certificate Evaluation"), () => {
frappe.model.open_mapped_doc({
method: "lms.lms.doctype.lms_certificate_request.lms_certificate_request.create_lms_certificate_evaluation",
frm: frm,
});
});
if (!frm.is_new()) {
frm.add_custom_button(
__("Create LMS Certificate Evaluation"),
() => {
frappe.model.open_mapped_doc({
method: "lms.lms.doctype.lms_certificate_request.lms_certificate_request.create_lms_certificate_evaluation",
frm: frm,
});
}
);
}
},
onload: function (frm) {

View File

@@ -7,12 +7,14 @@
"engine": "InnoDB",
"field_order": [
"course",
"member",
"member_name",
"evaluator",
"column_break_4",
"member",
"member_name",
"section_break_lifi",
"date",
"day",
"column_break_ddyh",
"start_time",
"end_time"
],
@@ -80,11 +82,19 @@
"fieldtype": "Data",
"label": "Member Name",
"read_only": 1
},
{
"fieldname": "section_break_lifi",
"fieldtype": "Section Break"
},
{
"fieldname": "column_break_ddyh",
"fieldtype": "Column Break"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2022-04-06 11:33:33.711545",
"modified": "2023-02-17 09:26:13.776325",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Certificate Request",
@@ -99,6 +109,7 @@
"read": 1,
"report": 1,
"role": "System Manager",
"select": 1,
"share": 1,
"write": 1
}

View File

@@ -12,6 +12,10 @@ class LMSCertificateRequest(Document):
def validate(self):
self.validate_if_existing_requests()
def after_insert(self):
if frappe.db.get_single_value("LMS Settings", "send_calendar_invite_for_evaluations"):
self.create_event()
def validate_if_existing_requests(self):
existing_requests = frappe.get_all(
"LMS Certificate Request",
@@ -30,6 +34,48 @@ class LMSCertificateRequest(Document):
)
)
def create_event(self):
calendar = frappe.db.get_value(
"Google Calendar", {"user": self.evaluator, "enable": 1}, "name"
)
if calendar:
event = frappe.get_doc(
{
"doctype": "Event",
"subject": f"Evaluation of {self.member_name}",
"starts_on": f"{self.date} {self.start_time}",
"ends_on": f"{self.date} {self.end_time}",
}
)
event.save()
participants = [self.member, self.evaluator]
for participant in participants:
contact_name = frappe.db.get_value("Contact", {"email_id": participant}, "name")
frappe.get_doc(
{
"doctype": "Event Participants",
"reference_doctype": "Contact",
"reference_docname": contact_name,
"email": participant,
"parent": event.name,
"parenttype": "Event",
"parentfield": "event_participants",
}
).save()
event.reload()
event.update(
{
"sync_with_google_calendar": 1,
"add_video_conferencing": 1,
"google_calendar": calendar,
}
)
event.save()
@frappe.whitelist()
def create_certificate_request(course, date, day, start_time, end_time):

View File

@@ -261,7 +261,7 @@
}
],
"make_attachments_public": 1,
"modified": "2022-09-14 13:26:53.153822",
"modified": "2023-02-16 10:11:17.557472",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Course",
@@ -295,7 +295,6 @@
}
],
"search_fields": "title",
"show_title_field_in_link": 1,
"sort_field": "creation",
"sort_order": "DESC",
"states": [],

View File

@@ -5,14 +5,18 @@
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"search_placeholder",
"portal_course_creation",
"default_home",
"is_onboarding_complete",
"column_break_zdel",
"send_calendar_invite_for_evaluations",
"force_profile_completion",
"section_break_szgq",
"search_placeholder",
"portal_course_creation",
"column_break_2",
"custom_certificate_template",
"livecode_url",
"force_profile_completion",
"signup_settings_tab",
"signup_settings_section",
"terms_of_use",
"terms_page",
@@ -23,6 +27,7 @@
"column_break_12",
"cookie_policy",
"cookie_policy_page",
"mentor_request_tab",
"mentor_request_section",
"mentor_request_creation",
"mentor_request_status_update"
@@ -82,8 +87,7 @@
},
{
"fieldname": "signup_settings_section",
"fieldtype": "Section Break",
"label": "Signup Settings"
"fieldtype": "Section Break"
},
{
"default": "0",
@@ -152,12 +156,36 @@
"fieldname": "default_home",
"fieldtype": "Check",
"label": "Make LMS the default home"
},
{
"fieldname": "column_break_zdel",
"fieldtype": "Column Break"
},
{
"default": "0",
"fieldname": "send_calendar_invite_for_evaluations",
"fieldtype": "Check",
"label": "Send calendar invite for evaluations"
},
{
"fieldname": "section_break_szgq",
"fieldtype": "Section Break"
},
{
"fieldname": "signup_settings_tab",
"fieldtype": "Tab Break",
"label": "Signup Settings"
},
{
"fieldname": "mentor_request_tab",
"fieldtype": "Tab Break",
"label": "Mentor Request"
}
],
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2023-02-07 19:53:46.073914",
"modified": "2023-02-15 17:13:11.802215",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Settings",

View File

@@ -4,7 +4,38 @@
import frappe
from frappe import _
from frappe.model.document import Document
from frappe.utils import get_url_to_list
class LMSSettings(Document):
pass
def validate(self):
self.validate_google_settings()
def validate_google_settings(self):
if self.send_calendar_invite_for_evaluations:
google_settings = frappe.get_single("Google Settings")
if not google_settings.enable:
frappe.throw(
_("Enable Google API in Google Settings to send calendar invites for evaluations.")
)
if not google_settings.client_id or not google_settings.client_secret:
frappe.throw(
_(
"Enter Client Id and Client Secret in Google Settings to send calendar invites for evaluations."
)
)
calendars = frappe.db.count("Google Calendar")
if not calendars:
frappe.throw(
_(
"Please add <a href='{0}'>{1}</a> for <a href='{2}'>{3}</a> to send calendar invites for evaluations."
).format(
get_url_to_list("Google Calendar"),
frappe.bold("Google Calendar"),
get_url_to_list("Course Evaluator"),
frappe.bold("Course Evaluator"),
)
)