Merge branch 'main' of https://github.com/frappe/lms into lms-frappe-ui
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe.utils import validate_url
|
from frappe.utils import validate_url, validate_email_address
|
||||||
from frappe.email.doctype.email_template.email_template import get_email_template
|
from frappe.email.doctype.email_template.email_template import get_email_template
|
||||||
|
|
||||||
|
|
||||||
@@ -43,6 +43,9 @@ class LMSAssignmentSubmission(Document):
|
|||||||
}
|
}
|
||||||
|
|
||||||
moderators = frappe.get_all("Has Role", {"role": "Moderator"}, pluck="parent")
|
moderators = frappe.get_all("Has Role", {"role": "Moderator"}, pluck="parent")
|
||||||
|
for moderator in moderators:
|
||||||
|
if not validate_email_address(moderator):
|
||||||
|
moderators.remove(moderator)
|
||||||
|
|
||||||
if custom_template:
|
if custom_template:
|
||||||
email_template = get_email_template(custom_template, args)
|
email_template = get_email_template(custom_template, args)
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
"column_break_iens",
|
"column_break_iens",
|
||||||
"amount",
|
"amount",
|
||||||
"currency",
|
"currency",
|
||||||
|
"amount_usd",
|
||||||
"customisations_tab",
|
"customisations_tab",
|
||||||
"section_break_ubxi",
|
"section_break_ubxi",
|
||||||
"custom_component",
|
"custom_component",
|
||||||
@@ -285,11 +286,18 @@
|
|||||||
"fieldname": "evaluation_end_date",
|
"fieldname": "evaluation_end_date",
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"label": "Evaluation End Date"
|
"label": "Evaluation End Date"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "paid_batch",
|
||||||
|
"description": "If you set an amount here, then the USD equivalent setting will not get applied.",
|
||||||
|
"fieldname": "amount_usd",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Amount (USD)"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2023-11-29 12:06:58.776479",
|
"modified": "2023-12-21 12:27:16.849362",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "LMS Batch",
|
"name": "LMS Batch",
|
||||||
|
|||||||
@@ -256,6 +256,7 @@ def create_batch(
|
|||||||
paid_batch=0,
|
paid_batch=0,
|
||||||
amount=0,
|
amount=0,
|
||||||
currency=None,
|
currency=None,
|
||||||
|
amount_usd=0,
|
||||||
name=None,
|
name=None,
|
||||||
published=0,
|
published=0,
|
||||||
evaluation_end_date=None,
|
evaluation_end_date=None,
|
||||||
@@ -274,7 +275,7 @@ def create_batch(
|
|||||||
"description": description,
|
"description": description,
|
||||||
"batch_details": batch_details,
|
"batch_details": batch_details,
|
||||||
"batch_details_raw": batch_details_raw,
|
"batch_details_raw": batch_details_raw,
|
||||||
"image": meta_image,
|
"meta_image": meta_image,
|
||||||
"seat_count": seat_count,
|
"seat_count": seat_count,
|
||||||
"start_time": start_time,
|
"start_time": start_time,
|
||||||
"end_time": end_time,
|
"end_time": end_time,
|
||||||
@@ -283,6 +284,7 @@ def create_batch(
|
|||||||
"paid_batch": paid_batch,
|
"paid_batch": paid_batch,
|
||||||
"amount": amount,
|
"amount": amount,
|
||||||
"currency": currency,
|
"currency": currency,
|
||||||
|
"amount_usd": amount_usd,
|
||||||
"published": published,
|
"published": published,
|
||||||
"evaluation_end_date": evaluation_end_date,
|
"evaluation_end_date": evaluation_end_date,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,12 +47,13 @@
|
|||||||
"fieldtype": "Rating",
|
"fieldtype": "Rating",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Rating",
|
"label": "Rating",
|
||||||
"reqd": 1
|
"mandatory_depends_on": "eval:doc.status != 'Pending' && doc.status != 'In Progress'"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "summary",
|
"fieldname": "summary",
|
||||||
"fieldtype": "Small Text",
|
"fieldtype": "Small Text",
|
||||||
"label": "Summary"
|
"label": "Summary",
|
||||||
|
"mandatory_depends_on": "eval:doc.status != 'Pending' && doc.status != 'In Progress'"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "date",
|
"fieldname": "date",
|
||||||
@@ -106,7 +107,7 @@
|
|||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2023-09-26 19:44:43.594892",
|
"modified": "2023-12-18 20:03:27.040073",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "LMS Certificate Evaluation",
|
"name": "LMS Certificate Evaluation",
|
||||||
|
|||||||
@@ -2,13 +2,19 @@
|
|||||||
# For license information, please see license.txt
|
# For license information, please see license.txt
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe import _
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
from lms.lms.utils import has_course_moderator_role
|
from lms.lms.utils import has_course_moderator_role
|
||||||
|
|
||||||
|
|
||||||
class LMSCertificateEvaluation(Document):
|
class LMSCertificateEvaluation(Document):
|
||||||
pass
|
def validate(self):
|
||||||
|
self.validate_rating()
|
||||||
|
|
||||||
|
def validate_rating(self):
|
||||||
|
if self.status not in ["Pending", "In Progress"] and self.rating == 0:
|
||||||
|
frappe.throw(_("Rating cannot be 0"))
|
||||||
|
|
||||||
|
|
||||||
def has_website_permission(doc, ptype, user, verbose=False):
|
def has_website_permission(doc, ptype, user, verbose=False):
|
||||||
|
|||||||
@@ -34,8 +34,10 @@
|
|||||||
"related_courses",
|
"related_courses",
|
||||||
"pricing_section",
|
"pricing_section",
|
||||||
"paid_course",
|
"paid_course",
|
||||||
"currency",
|
"column_break_acoj",
|
||||||
"course_price",
|
"course_price",
|
||||||
|
"currency",
|
||||||
|
"amount_usd",
|
||||||
"certification_section",
|
"certification_section",
|
||||||
"enable_certification",
|
"enable_certification",
|
||||||
"expiry",
|
"expiry",
|
||||||
@@ -222,12 +224,22 @@
|
|||||||
"fieldname": "course_price",
|
"fieldname": "course_price",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"label": "Course Price",
|
"label": "Course Price",
|
||||||
"option": "currency",
|
|
||||||
"mandatory_depends_on": "paid_course"
|
"mandatory_depends_on": "paid_course"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "column_break_rxww",
|
"fieldname": "column_break_rxww",
|
||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_acoj",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "paid_course",
|
||||||
|
"description": "If you set an amount here, then the USD equivalent setting will not get applied.",
|
||||||
|
"fieldname": "amount_usd",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"label": "Amount (USD)"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"is_published_field": "published",
|
"is_published_field": "published",
|
||||||
@@ -254,7 +266,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"make_attachments_public": 1,
|
"make_attachments_public": 1,
|
||||||
"modified": "2023-08-28 11:09:11.945066",
|
"modified": "2023-12-21 12:27:32.559901",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "LMS Course",
|
"name": "LMS Course",
|
||||||
|
|||||||
@@ -911,8 +911,9 @@ def get_payment_options(doctype, docname, phone, country):
|
|||||||
|
|
||||||
validate_phone_number(phone, True)
|
validate_phone_number(phone, True)
|
||||||
details = get_details(doctype, docname)
|
details = get_details(doctype, docname)
|
||||||
|
|
||||||
details.amount, details.currency = check_multicurrency(
|
details.amount, details.currency = check_multicurrency(
|
||||||
details.amount, details.currency, country
|
details.amount, details.currency, country, details.amount_usd
|
||||||
)
|
)
|
||||||
if details.currency == "INR":
|
if details.currency == "INR":
|
||||||
details.amount, details.gst_applied = apply_gst(details.amount, country)
|
details.amount, details.gst_applied = apply_gst(details.amount, country)
|
||||||
@@ -936,16 +937,20 @@ def get_payment_options(doctype, docname, phone, country):
|
|||||||
return options
|
return options
|
||||||
|
|
||||||
|
|
||||||
def check_multicurrency(amount, currency, country=None):
|
def check_multicurrency(amount, currency, country=None, amount_usd=None):
|
||||||
show_usd_equivalent = frappe.db.get_single_value("LMS Settings", "show_usd_equivalent")
|
show_usd_equivalent = frappe.db.get_single_value("LMS Settings", "show_usd_equivalent")
|
||||||
exception_country = frappe.get_all(
|
exception_country = frappe.get_all(
|
||||||
"Payment Country", filters={"parent": "LMS Settings"}, pluck="country"
|
"Payment Country", filters={"parent": "LMS Settings"}, pluck="country"
|
||||||
)
|
)
|
||||||
apply_rounding = frappe.db.get_single_value("LMS Settings", "apply_rounding")
|
country = (
|
||||||
country = country or frappe.db.get_value(
|
country
|
||||||
"Address", {"email_id": frappe.session.user}, "country"
|
or frappe.db.get_value("Address", {"email_id": frappe.session.user}, "country")
|
||||||
|
or frappe.db.get_value("User", frappe.session.user, "country")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if amount_usd and country not in exception_country:
|
||||||
|
return amount_usd, "USD"
|
||||||
|
|
||||||
if not show_usd_equivalent or currency == "USD":
|
if not show_usd_equivalent or currency == "USD":
|
||||||
return amount, currency
|
return amount, currency
|
||||||
|
|
||||||
@@ -956,6 +961,7 @@ def check_multicurrency(amount, currency, country=None):
|
|||||||
amount = amount * exchange_rate
|
amount = amount * exchange_rate
|
||||||
currency = "USD"
|
currency = "USD"
|
||||||
|
|
||||||
|
apply_rounding = frappe.db.get_single_value("LMS Settings", "apply_rounding")
|
||||||
if apply_rounding and amount % 100 != 0:
|
if apply_rounding and amount % 100 != 0:
|
||||||
amount = amount + 100 - amount % 100
|
amount = amount + 100 - amount % 100
|
||||||
|
|
||||||
@@ -981,7 +987,7 @@ def get_details(doctype, docname):
|
|||||||
details = frappe.db.get_value(
|
details = frappe.db.get_value(
|
||||||
"LMS Course",
|
"LMS Course",
|
||||||
docname,
|
docname,
|
||||||
["name", "title", "paid_course", "currency", "course_price as amount"],
|
["name", "title", "paid_course", "currency", "course_price as amount", "amount_usd"],
|
||||||
as_dict=True,
|
as_dict=True,
|
||||||
)
|
)
|
||||||
if not details.paid_course:
|
if not details.paid_course:
|
||||||
@@ -990,7 +996,7 @@ def get_details(doctype, docname):
|
|||||||
details = frappe.db.get_value(
|
details = frappe.db.get_value(
|
||||||
"LMS Batch",
|
"LMS Batch",
|
||||||
docname,
|
docname,
|
||||||
["name", "title", "paid_batch", "currency", "amount"],
|
["name", "title", "paid_batch", "currency", "amount", "amount_usd"],
|
||||||
as_dict=True,
|
as_dict=True,
|
||||||
)
|
)
|
||||||
if not details.paid_batch:
|
if not details.paid_batch:
|
||||||
@@ -1102,9 +1108,10 @@ def get_payment_details(doctype, docname, address):
|
|||||||
amount_field = "course_price" if doctype == "LMS Course" else "amount"
|
amount_field = "course_price" if doctype == "LMS Course" else "amount"
|
||||||
amount = frappe.db.get_value(doctype, docname, amount_field)
|
amount = frappe.db.get_value(doctype, docname, amount_field)
|
||||||
currency = frappe.db.get_value(doctype, docname, "currency")
|
currency = frappe.db.get_value(doctype, docname, "currency")
|
||||||
|
amount_usd = frappe.db.get_value(doctype, docname, "amount_usd")
|
||||||
amount_with_gst = 0
|
amount_with_gst = 0
|
||||||
|
|
||||||
amount, currency = check_multicurrency(amount, currency)
|
amount, currency = check_multicurrency(amount, currency, None, amount_usd)
|
||||||
if currency == "INR" and address.country == "India":
|
if currency == "INR" and address.country == "India":
|
||||||
amount_with_gst, gst_applied = apply_gst(amount, address.country)
|
amount_with_gst, gst_applied = apply_gst(amount, address.country)
|
||||||
|
|
||||||
|
|||||||
@@ -392,6 +392,15 @@ const open_batch_dialog = () => {
|
|||||||
depends_on: "paid_batch",
|
depends_on: "paid_batch",
|
||||||
only_select: 1,
|
only_select: 1,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
fieldtype: "Currency",
|
||||||
|
label: __("Amount (USD)"),
|
||||||
|
fieldname: "amount_usd",
|
||||||
|
depends_on: "paid_batch",
|
||||||
|
description: __(
|
||||||
|
"If you set an amount here, then the USD equivalent setting will not get applied."
|
||||||
|
),
|
||||||
|
},
|
||||||
],
|
],
|
||||||
primary_action_label: __("Save"),
|
primary_action_label: __("Save"),
|
||||||
primary_action: (values) => {
|
primary_action: (values) => {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
</p>
|
</p>
|
||||||
<br>
|
<br>
|
||||||
<p>
|
<p>
|
||||||
{{ _("I am pleased to inform you that your enrollment for the upcoming training batch has been successfully processed. Congratulations!") }}
|
{{ _("We are pleased to inform you that you have been enrolled in our upcoming batch. Congratulations!") }}
|
||||||
</p>
|
</p>
|
||||||
<br>
|
<br>
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ def get_context(context):
|
|||||||
"published",
|
"published",
|
||||||
"allow_future",
|
"allow_future",
|
||||||
"evaluation_end_date",
|
"evaluation_end_date",
|
||||||
|
"meta_image",
|
||||||
],
|
],
|
||||||
as_dict=True,
|
as_dict=True,
|
||||||
)
|
)
|
||||||
@@ -156,7 +157,6 @@ def get_class_course_details(batch_courses):
|
|||||||
"image",
|
"image",
|
||||||
"upcoming",
|
"upcoming",
|
||||||
"short_introduction",
|
"short_introduction",
|
||||||
"image",
|
|
||||||
"paid_course",
|
"paid_course",
|
||||||
"course_price",
|
"course_price",
|
||||||
"enable_certification",
|
"enable_certification",
|
||||||
|
|||||||
@@ -34,13 +34,17 @@ def get_context(context):
|
|||||||
"meta_image",
|
"meta_image",
|
||||||
"batch_details_raw",
|
"batch_details_raw",
|
||||||
"evaluation_end_date",
|
"evaluation_end_date",
|
||||||
|
"amount_usd",
|
||||||
],
|
],
|
||||||
as_dict=1,
|
as_dict=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
if context.batch_info.amount and context.batch_info.currency:
|
if context.batch_info.amount and context.batch_info.currency:
|
||||||
amount, currency = check_multicurrency(
|
amount, currency = check_multicurrency(
|
||||||
context.batch_info.amount, context.batch_info.currency
|
context.batch_info.amount,
|
||||||
|
context.batch_info.currency,
|
||||||
|
None,
|
||||||
|
context.batch_info.amount_usd,
|
||||||
)
|
)
|
||||||
context.batch_info.amount = amount
|
context.batch_info.amount = amount
|
||||||
context.batch_info.currency = currency
|
context.batch_info.currency = currency
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ def get_context(context):
|
|||||||
"currency",
|
"currency",
|
||||||
"seat_count",
|
"seat_count",
|
||||||
"published",
|
"published",
|
||||||
|
"amount_usd",
|
||||||
],
|
],
|
||||||
order_by="start_date",
|
order_by="start_date",
|
||||||
)
|
)
|
||||||
@@ -36,7 +37,9 @@ def get_context(context):
|
|||||||
batch.course_count = frappe.db.count("Batch Course", {"parent": batch.name})
|
batch.course_count = frappe.db.count("Batch Course", {"parent": batch.name})
|
||||||
|
|
||||||
if batch.amount and batch.currency:
|
if batch.amount and batch.currency:
|
||||||
amount, currency = check_multicurrency(batch.amount, batch.currency)
|
amount, currency = check_multicurrency(
|
||||||
|
batch.amount, batch.currency, None, batch.amount_usd
|
||||||
|
)
|
||||||
batch.amount = amount
|
batch.amount = amount
|
||||||
batch.currency = currency
|
batch.currency = currency
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ def get_context(context):
|
|||||||
)
|
)
|
||||||
|
|
||||||
context.amount, context.currency = check_multicurrency(
|
context.amount, context.currency = check_multicurrency(
|
||||||
context.amount, context.currency
|
context.amount, context.currency, None, context.amount_usd
|
||||||
)
|
)
|
||||||
|
|
||||||
context.address = get_address()
|
context.address = get_address()
|
||||||
@@ -65,7 +65,7 @@ def get_billing_details(context):
|
|||||||
details = frappe.db.get_value(
|
details = frappe.db.get_value(
|
||||||
"LMS Course",
|
"LMS Course",
|
||||||
context.docname,
|
context.docname,
|
||||||
["title", "name", "paid_course", "course_price as amount", "currency"],
|
["title", "name", "paid_course", "course_price as amount", "currency", "amount_usd"],
|
||||||
as_dict=True,
|
as_dict=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ def get_billing_details(context):
|
|||||||
details = frappe.db.get_value(
|
details = frappe.db.get_value(
|
||||||
"LMS Batch",
|
"LMS Batch",
|
||||||
context.docname,
|
context.docname,
|
||||||
["title", "name", "paid_batch", "amount", "currency"],
|
["title", "name", "paid_batch", "amount", "currency", "amount_usd"],
|
||||||
as_dict=True,
|
as_dict=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -88,6 +88,7 @@ def get_billing_details(context):
|
|||||||
context.title = details.title
|
context.title = details.title
|
||||||
context.amount = details.amount
|
context.amount = details.amount
|
||||||
context.currency = details.currency
|
context.currency = details.currency
|
||||||
|
context.amount_usd = details.amount_usd
|
||||||
|
|
||||||
|
|
||||||
def get_address():
|
def get_address():
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ def set_course_context(context, course_name):
|
|||||||
"paid_course",
|
"paid_course",
|
||||||
"course_price",
|
"course_price",
|
||||||
"currency",
|
"currency",
|
||||||
|
"amount_usd",
|
||||||
"enable_certification",
|
"enable_certification",
|
||||||
"grant_certificate_after",
|
"grant_certificate_after",
|
||||||
],
|
],
|
||||||
@@ -64,7 +65,7 @@ def set_course_context(context, course_name):
|
|||||||
|
|
||||||
if course.course_price:
|
if course.course_price:
|
||||||
course.course_price, course.currency = check_multicurrency(
|
course.course_price, course.currency = check_multicurrency(
|
||||||
course.course_price, course.currency
|
course.course_price, course.currency, None, course.amount_usd
|
||||||
)
|
)
|
||||||
|
|
||||||
if frappe.form_dict.get("edit"):
|
if frappe.form_dict.get("edit"):
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ def get_courses():
|
|||||||
"course_price",
|
"course_price",
|
||||||
"currency",
|
"currency",
|
||||||
"creation",
|
"creation",
|
||||||
|
"amount_usd",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -72,7 +73,7 @@ def get_courses():
|
|||||||
|
|
||||||
if course.course_price:
|
if course.course_price:
|
||||||
course.course_price, course.currency = check_multicurrency(
|
course.course_price, course.currency = check_multicurrency(
|
||||||
course.course_price, course.currency
|
course.course_price, course.currency, None, course.amount_usd
|
||||||
)
|
)
|
||||||
|
|
||||||
course.avg_rating = get_average_rating(course.name) or 0
|
course.avg_rating = get_average_rating(course.name) or 0
|
||||||
|
|||||||
Reference in New Issue
Block a user