diff --git a/lms/hooks.py b/lms/hooks.py index 81783b67..99d428cf 100644 --- a/lms/hooks.py +++ b/lms/hooks.py @@ -189,7 +189,8 @@ jinja = { "lms.lms.utils.is_instructor", "lms.lms.utils.convert_number_to_character", "lms.lms.utils.get_signup_optin_checks", - "lms.lms.utils.get_popular_courses" + "lms.lms.utils.get_popular_courses", + "lms.lms.utils.format_amount" ], "filters": [] } diff --git a/lms/lms/doctype/lms_course/lms_course.json b/lms/lms/doctype/lms_course/lms_course.json index 529ccd48..1a12c77a 100644 --- a/lms/lms/doctype/lms_course/lms_course.json +++ b/lms/lms/doctype/lms_course/lms_course.json @@ -203,13 +203,15 @@ "depends_on": "paid_certificate", "fieldname": "price_certificate", "fieldtype": "Currency", - "label": "Certificate Price" + "label": "Certificate Price", + "mandatory_depends_on": "paid_certificate" }, { "depends_on": "paid_certificate", "fieldname": "currency", "fieldtype": "Link", "label": "Currency", + "mandatory_depends_on": "paid_certificate", "options": "Currency" }, { @@ -258,7 +260,7 @@ "link_fieldname": "course" } ], - "modified": "2022-05-04 11:03:24.001015", + "modified": "2022-05-19 16:59:21.933367", "modified_by": "Administrator", "module": "LMS", "name": "LMS Course", diff --git a/lms/lms/utils.py b/lms/lms/utils.py index 6e1120e7..7b550d51 100644 --- a/lms/lms/utils.py +++ b/lms/lms/utils.py @@ -1,6 +1,6 @@ import re import frappe -from frappe.utils import flt, cint, cstr, getdate, add_months +from frappe.utils import flt, cint, cstr, getdate, add_months, fmt_money from lms.lms.md import markdown_to_html, find_macros import string from frappe import _ @@ -366,3 +366,10 @@ def get_evaluation_details(course, member=None): "request": request, "no_of_attempts": no_of_attempts }) + +def format_amount(amount, currency): + amount_reduced = amount / 1000 + if amount_reduced < 1: + return amount + precision = 0 if amount % 1000 == 0 else 1 + return _("{0}K").format(fmt_money(amount_reduced, precision, currency)) diff --git a/lms/lms/widgets/CourseCard.html b/lms/lms/widgets/CourseCard.html index 75c20ca6..05908ca7 100644 --- a/lms/lms/widgets/CourseCard.html +++ b/lms/lms/widgets/CourseCard.html @@ -68,7 +68,7 @@ {% if course.paid_certificate %}