chore: renamed lms certification to lms certificate
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
// Copyright (c) 2021, FOSS United and contributors
|
// Copyright (c) 2021, FOSS United and contributors
|
||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
frappe.ui.form.on('LMS Certification', {
|
frappe.ui.form.on('LMS Certificate', {
|
||||||
onload: function (frm) {
|
onload: function (frm) {
|
||||||
frm.set_query("student", function (doc) {
|
frm.set_query("student", function (doc) {
|
||||||
return {
|
return {
|
||||||
@@ -6,25 +6,18 @@
|
|||||||
"editable_grid": 1,
|
"editable_grid": 1,
|
||||||
"engine": "InnoDB",
|
"engine": "InnoDB",
|
||||||
"field_order": [
|
"field_order": [
|
||||||
"student",
|
|
||||||
"issue_date",
|
|
||||||
"column_break_3",
|
|
||||||
"course",
|
"course",
|
||||||
|
"member",
|
||||||
|
"column_break_3",
|
||||||
|
"issue_date",
|
||||||
"expiry_date"
|
"expiry_date"
|
||||||
],
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
|
||||||
"fieldname": "student",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"in_list_view": 1,
|
|
||||||
"in_standard_filter": 1,
|
|
||||||
"label": "Student",
|
|
||||||
"options": "User"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname": "issue_date",
|
"fieldname": "issue_date",
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"label": "Issue Date"
|
"label": "Issue Date",
|
||||||
|
"reqd": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "column_break_3",
|
"fieldname": "column_break_3",
|
||||||
@@ -36,20 +29,30 @@
|
|||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"in_standard_filter": 1,
|
"in_standard_filter": 1,
|
||||||
"label": "Course",
|
"label": "Course",
|
||||||
"options": "LMS Course"
|
"options": "LMS Course",
|
||||||
|
"reqd": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "expiry_date",
|
"fieldname": "expiry_date",
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"label": "Expiry Date"
|
"label": "Expiry Date"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "member",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"in_standard_filter": 1,
|
||||||
|
"label": "Member",
|
||||||
|
"options": "User",
|
||||||
|
"reqd": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2022-04-01 16:41:10.213765",
|
"modified": "2022-04-01 18:40:27.651944",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "LMS Certification",
|
"name": "LMS Certificate",
|
||||||
"naming_rule": "Expression",
|
"naming_rule": "Expression",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
@@ -8,16 +8,16 @@ from frappe import _
|
|||||||
from frappe.utils.pdf import get_pdf
|
from frappe.utils.pdf import get_pdf
|
||||||
from lms.lms.utils import is_certified
|
from lms.lms.utils import is_certified
|
||||||
|
|
||||||
class LMSCertification(Document):
|
class LMSCertificate(Document):
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
certificates = frappe.get_all("LMS Certification", {
|
certificates = frappe.get_all("LMS Certificate", {
|
||||||
"student": self.student,
|
"member": self.member,
|
||||||
"course": self.course,
|
"course": self.course,
|
||||||
"expiry_date": [">", nowdate()]
|
"expiry_date": [">", nowdate()]
|
||||||
})
|
})
|
||||||
if len(certificates):
|
if len(certificates):
|
||||||
full_name = frappe.db.get_value("User", self.student, "full_name")
|
full_name = frappe.db.get_value("User", self.member, "full_name")
|
||||||
course_name = frappe.db.get_value("LMS Course", self.course, "title")
|
course_name = frappe.db.get_value("LMS Course", self.course, "title")
|
||||||
frappe.throw(_("There is already a valid certificate for user {0} for the course {1}").format(full_name, course_name))
|
frappe.throw(_("There is already a valid certificate for user {0} for the course {1}").format(full_name, course_name))
|
||||||
|
|
||||||
@@ -35,8 +35,8 @@ def create_certificate(course):
|
|||||||
expiry_date = add_years(nowdate(), expires_after_yrs)
|
expiry_date = add_years(nowdate(), expires_after_yrs)
|
||||||
|
|
||||||
certificate = frappe.get_doc({
|
certificate = frappe.get_doc({
|
||||||
"doctype": "LMS Certification",
|
"doctype": "LMS Certificate",
|
||||||
"student": frappe.session.user,
|
"member": frappe.session.user,
|
||||||
"course": course,
|
"course": course,
|
||||||
"issue_date": nowdate(),
|
"issue_date": nowdate(),
|
||||||
"expiry_date": expiry_date
|
"expiry_date": expiry_date
|
||||||
@@ -4,19 +4,19 @@
|
|||||||
import frappe
|
import frappe
|
||||||
import unittest
|
import unittest
|
||||||
from lms.lms.doctype.lms_course.test_lms_course import new_course
|
from lms.lms.doctype.lms_course.test_lms_course import new_course
|
||||||
from lms.lms.doctype.lms_certification.lms_certification import create_certificate
|
from lms.lms.doctype.lms_certificate.lms_certificate import create_certificate
|
||||||
from frappe.utils import nowdate, add_years, cint
|
from frappe.utils import nowdate, add_years, cint
|
||||||
|
|
||||||
class TestLMSCertification(unittest.TestCase):
|
class TestLMSCertificate(unittest.TestCase):
|
||||||
|
|
||||||
def test_certificate_creation(self):
|
def test_certificate_creation(self):
|
||||||
course = new_course("Test Certificate", 1, 2)
|
course = new_course("Test Certificate", 1, 2)
|
||||||
certificate = create_certificate(course.name)
|
certificate = create_certificate(course.name)
|
||||||
|
|
||||||
self.assertEqual(certificate.student, "Administrator")
|
self.assertEqual(certificate.member, "Administrator")
|
||||||
self.assertEqual(certificate.course, course.name)
|
self.assertEqual(certificate.course, course.name)
|
||||||
self.assertEqual(certificate.issue_date, nowdate())
|
self.assertEqual(certificate.issue_date, nowdate())
|
||||||
self.assertEqual(certificate.expiry_date, add_years(nowdate(), cint(course.expiry)))
|
self.assertEqual(certificate.expiry_date, add_years(nowdate(), cint(course.expiry)))
|
||||||
|
|
||||||
frappe.db.delete("LMS Certification", certificate.name)
|
frappe.db.delete("LMS Certificate", certificate.name)
|
||||||
frappe.db.delete("LMS Course", course.name)
|
frappe.db.delete("LMS Course", course.name)
|
||||||
@@ -2,6 +2,15 @@
|
|||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
frappe.ui.form.on('LMS Certificate Evaluation', {
|
frappe.ui.form.on('LMS Certificate Evaluation', {
|
||||||
|
refresh: function(frm) {
|
||||||
|
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",
|
||||||
|
frm: frm
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
onload: function(frm) {
|
onload: function(frm) {
|
||||||
frm.set_query("course", function(doc) {
|
frm.set_query("course", function(doc) {
|
||||||
return {
|
return {
|
||||||
@@ -11,13 +20,5 @@ frappe.ui.form.on('LMS Certificate Evaluation', {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
frm.set_query("member", function(doc) {
|
|
||||||
return {
|
|
||||||
filters: {
|
|
||||||
"course": doc.course,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,8 +1,18 @@
|
|||||||
# Copyright (c) 2022, Frappe and contributors
|
# Copyright (c) 2022, Frappe and contributors
|
||||||
# For license information, please see license.txt
|
# For license information, please see license.txt
|
||||||
|
|
||||||
# import frappe
|
import frappe
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
from frappe.model.mapper import get_mapped_doc
|
||||||
|
|
||||||
class LMSCertificateEvaluation(Document):
|
class LMSCertificateEvaluation(Document):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def create_lms_certificate(source_name, target_doc=None):
|
||||||
|
doc = get_mapped_doc("LMS Certificate Evaluation", source_name, {
|
||||||
|
"LMS Certificate Evaluation": {
|
||||||
|
"doctype": "LMS Certificate"
|
||||||
|
}
|
||||||
|
}, target_doc)
|
||||||
|
return doc
|
||||||
|
|||||||
@@ -170,9 +170,9 @@ def get_sorted_reviews(course):
|
|||||||
return rating_percent
|
return rating_percent
|
||||||
|
|
||||||
def is_certified(course):
|
def is_certified(course):
|
||||||
certificate = frappe.get_all("LMS Certification",
|
certificate = frappe.get_all("LMS Certificate",
|
||||||
{
|
{
|
||||||
"student": frappe.session.user,
|
"member": frappe.session.user,
|
||||||
"course": course
|
"course": course
|
||||||
})
|
})
|
||||||
if len(certificate):
|
if len(certificate):
|
||||||
|
|||||||
@@ -26,3 +26,5 @@ school.patches.v0_0.set_course_in_lesson #21-03-2022
|
|||||||
school.patches.v0_0.set_status_in_course #21-03-2022
|
school.patches.v0_0.set_status_in_course #21-03-2022
|
||||||
lms.patches.v0_0.change_published_field_data #25-03-2022
|
lms.patches.v0_0.change_published_field_data #25-03-2022
|
||||||
execute:frappe.delete_doc("Workspace", "School", ignore_missing=True, force=True)
|
execute:frappe.delete_doc("Workspace", "School", ignore_missing=True, force=True)
|
||||||
|
lms.patches.v0_0.certification_member_field_data #01-04-2022
|
||||||
|
lms.patches.v0_0.move_certification_to_certificate
|
||||||
|
|||||||
7
lms/patches/v0_0/certification_member_field_data.py
Normal file
7
lms/patches/v0_0/certification_member_field_data.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import frappe
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
frappe.reload_doc("lms", "doctype", "lms_certification")
|
||||||
|
certificates = frappe.get_all("LMS Certification", fields=["name", "student"])
|
||||||
|
for certificate in certificates:
|
||||||
|
frappe.db.set_value("LMS Certification", certificate.name, "member", certificate.student)
|
||||||
12
lms/patches/v0_0/move_certification_to_certificate.py
Normal file
12
lms/patches/v0_0/move_certification_to_certificate.py
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import frappe
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
old = frappe.get_all("LMS Certification", fields=["name", "course", "member", "student", "issue_date", "expiry_date"])
|
||||||
|
for data in old:
|
||||||
|
frappe.get_doc({
|
||||||
|
"doctype": "LMS Certificate",
|
||||||
|
"course": data.course,
|
||||||
|
"member": data.member or data.student,
|
||||||
|
"issue_date": data.issue_date,
|
||||||
|
"expiry_date": data.expiry_date
|
||||||
|
}).save(ignore_permissions=True)
|
||||||
@@ -244,7 +244,7 @@ const create_certificate = (e) => {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
course = $(".title").attr("data-course");
|
course = $(".title").attr("data-course");
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "lms.lms.doctype.lms_certification.lms_certification.create_certificate",
|
method: "lms.lms.doctype.lms_certificate.lms_certificate.create_certificate",
|
||||||
args: {
|
args: {
|
||||||
"course": course
|
"course": course
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ def get_context(context):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
redirect_to_course_list()
|
redirect_to_course_list()
|
||||||
|
|
||||||
context.certificate = frappe.db.get_value("LMS Certification", certificate_name,
|
context.certificate = frappe.db.get_value("LMS Certificate", certificate_name,
|
||||||
["name", "student", "issue_date", "expiry_date", "course"], as_dict=True)
|
["name", "student", "issue_date", "expiry_date", "course"], as_dict=True)
|
||||||
|
|
||||||
if context.certificate.course != course_name:
|
if context.certificate.course != course_name:
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ const create_certificate = (e) => {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
course = $(e.currentTarget).attr("data-course");
|
course = $(e.currentTarget).attr("data-course");
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "lms.lms.doctype.lms_certification.lms_certification.create_certificate",
|
method: "lms.lms.doctype.lms_certificate.lms_certificate.create_certificate",
|
||||||
args: {
|
args: {
|
||||||
"course": course
|
"course": course
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user