From 5ab9131629f39c6b1f59235dd8d92fc9d4db7225 Mon Sep 17 00:00:00 2001
From: Jannat Patel
Date: Thu, 13 Feb 2025 16:57:21 +0530
Subject: [PATCH 1/3] fix: misc batch issues
---
frontend/src/components/BatchFeedback.vue | 4 +--
frontend/src/components/BatchStudents.vue | 4 +--
.../components/Modals/AnnouncementModal.vue | 7 ++--
.../Modals/BatchStudentProgress.vue | 33 +++++++++++++++----
frontend/src/pages/BatchDetail.vue | 5 +++
lms/lms/api.py | 29 +++++-----------
.../lms_batch_enrollment.py | 14 ++++----
lms/lms/utils.py | 21 ++++++++----
lms/templates/emails/batch_confirmation.html | 8 +----
lms/templates/emails/payment_reminder.html | 8 ++++-
10 files changed, 80 insertions(+), 53 deletions(-)
diff --git a/frontend/src/components/BatchFeedback.vue b/frontend/src/components/BatchFeedback.vue
index 5a7e0204..fb2cb3ca 100644
--- a/frontend/src/components/BatchFeedback.vue
+++ b/frontend/src/components/BatchFeedback.vue
@@ -78,7 +78,7 @@
{
diff --git a/frontend/src/components/BatchStudents.vue b/frontend/src/components/BatchStudents.vue
index fd3f8ff3..dc21e311 100644
--- a/frontend/src/components/BatchStudents.vue
+++ b/frontend/src/components/BatchStudents.vue
@@ -78,7 +78,7 @@
:options="chartOptions"
:series="chartData"
type="bar"
- height="200"
+ :height="chartData[0].data.length * 30 + 100"
/>
{
})
Object.keys(student.assessments).forEach((assessment) => {
- if (student.assessments[assessment].result === 'Passed') {
+ if (student.assessments[assessment].result === 'Pass') {
categories[assessment].value += 1
}
})
diff --git a/frontend/src/components/Modals/AnnouncementModal.vue b/frontend/src/components/Modals/AnnouncementModal.vue
index 5f07d866..bcb9f30e 100644
--- a/frontend/src/components/Modals/AnnouncementModal.vue
+++ b/frontend/src/components/Modals/AnnouncementModal.vue
@@ -67,13 +67,16 @@ const announcement = reactive({
})
const announcementResource = createResource({
- url: 'lms.lms.api.make_announcement',
+ url: 'frappe.core.doctype.communication.email.make',
makeParams(values) {
return {
- students: props.students,
+ recipients: props.students.join(', '),
cc: announcement.replyTo,
subject: announcement.subject,
content: announcement.announcement,
+ doctype: 'LMS Batch',
+ name: props.batch,
+ send_email: 1,
}
},
})
diff --git a/frontend/src/components/Modals/BatchStudentProgress.vue b/frontend/src/components/Modals/BatchStudentProgress.vue
index 7896f42a..e2bf3add 100644
--- a/frontend/src/components/Modals/BatchStudentProgress.vue
+++ b/frontend/src/components/Modals/BatchStudentProgress.vue
@@ -32,25 +32,44 @@
{{ __('Assessment') }}
- {{ __('Progress') }}
+ {{ __('Percentage/Status') }}
-
{{ assessment }}
-
-
- {{ student.assessments[assessment] }}
+
+
+ {{ student.assessments[assessment].status }}
- {{ student.assessments[assessment] }}
+ {{ student.assessments[assessment].status }}
-
+
diff --git a/frontend/src/pages/BatchDetail.vue b/frontend/src/pages/BatchDetail.vue
index 8c7b447c..24d243ec 100644
--- a/frontend/src/pages/BatchDetail.vue
+++ b/frontend/src/pages/BatchDetail.vue
@@ -127,6 +127,11 @@ const batch = createResource({
batch: props.batchName,
},
auto: true,
+ onSuccess: (data) => {
+ if (!data) {
+ router.push({ name: 'Batches' })
+ }
+ },
})
const courses = createResource({
diff --git a/lms/lms/api.py b/lms/lms/api.py
index 9fe46a43..afae3e15 100644
--- a/lms/lms/api.py
+++ b/lms/lms/api.py
@@ -7,15 +7,10 @@ import zipfile
import os
import re
import shutil
-import requests
import xml.etree.ElementTree as ET
from frappe.translate import get_all_translations
from frappe import _
-from frappe.query_builder import DocType
-from frappe.query_builder.functions import Count
from frappe.utils import (
- time_diff,
- now_datetime,
get_datetime,
cint,
flt,
@@ -24,10 +19,10 @@ from frappe.utils import (
format_date,
date_diff,
)
-from typing import Optional
from lms.lms.utils import get_average_rating, get_lesson_count
from xml.dom.minidom import parseString
from lms.lms.doctype.course_lesson.course_lesson import save_progress
+from frappe.core.doctype.communication.email import make
@frappe.whitelist()
@@ -845,7 +840,7 @@ def update_course_statistics():
@frappe.whitelist()
def get_announcements(batch):
- return frappe.get_all(
+ communications = frappe.get_all(
"Communication",
filters={
"reference_doctype": "LMS Batch",
@@ -863,6 +858,13 @@ def get_announcements(batch):
order_by="communication_date desc",
)
+ for communication in communications:
+ communication.image = frappe.get_cached_value(
+ "User", communication.sender, "user_image"
+ )
+
+ return communications
+
@frappe.whitelist()
def delete_course(course):
@@ -1225,16 +1227,3 @@ def get_notifications(filters):
@frappe.whitelist(allow_guest=True)
def is_guest_allowed():
return frappe.get_cached_value("LMS Settings", None, "allow_guest_access")
-
-
-@frappe.whitelist()
-def make_announcement(students, cc, subject, content):
- for student in students:
- frappe.sendmail(
- recipients=student,
- cc=cc,
- subject=subject,
- message=content,
- header=[subject, "green"],
- retry=3,
- )
diff --git a/lms/lms/doctype/lms_batch_enrollment/lms_batch_enrollment.py b/lms/lms/doctype/lms_batch_enrollment/lms_batch_enrollment.py
index bab1ee6a..8fd3124c 100644
--- a/lms/lms/doctype/lms_batch_enrollment/lms_batch_enrollment.py
+++ b/lms/lms/doctype/lms_batch_enrollment/lms_batch_enrollment.py
@@ -76,17 +76,19 @@ def send_confirmation_email(doc):
def send_mail(doc):
- subject = _("Enrollment Confirmation for the Next Training Batch")
- template = "batch_confirmation"
- custom_template = frappe.db.get_single_value(
- "LMS Settings", "batch_confirmation_template"
- )
batch = frappe.db.get_value(
"LMS Batch",
doc.batch,
["name", "title", "start_date", "start_time", "medium"],
as_dict=1,
)
+
+ subject = _("Enrollment Confirmation for {0}").format(batch.title)
+ template = "batch_confirmation"
+ custom_template = frappe.db.get_single_value(
+ "LMS Settings", "batch_confirmation_template"
+ )
+
args = {
"title": batch.title,
"student_name": doc.member_name,
@@ -107,6 +109,6 @@ def send_mail(doc):
template=template if not custom_template else None,
content=content if custom_template else None,
args=args,
- header=[subject, "green"],
+ header=[_(batch.title), "green"],
retry=3,
)
diff --git a/lms/lms/utils.py b/lms/lms/utils.py
index c7a82860..5dcccd16 100644
--- a/lms/lms/utils.py
+++ b/lms/lms/utils.py
@@ -1194,6 +1194,9 @@ def get_neighbour_lesson(course, chapter, lesson):
@frappe.whitelist(allow_guest=True)
def get_batch_details(batch):
+ if not frappe.db.get_value("LMS Batch", batch, "published") and has_student_role():
+ return
+
batch_details = frappe.db.get_value(
"LMS Batch",
batch,
@@ -1450,7 +1453,7 @@ def get_batch_students(batch):
)
detail.assessments[title] = assessment_info
- if assessment_info.result == "Passed":
+ if assessment_info.result == "Pass":
assessments_completed += 1
detail.courses_completed = courses_completed
@@ -1493,20 +1496,26 @@ def has_submitted_assessment(assessment, assessment_type, member=None):
attempt = frappe.db.exists(doctype, filters)
if attempt:
- attempt_details = frappe.db.get_value(doctype, filters, fields)
+ fields.append("name")
+ attempt_details = frappe.db.get_value(doctype, filters, fields, as_dict=1)
if assessment_type == "LMS Quiz":
result = "Failed"
passing_percentage = frappe.db.get_value(
"LMS Quiz", assessment, "passing_percentage"
)
- if attempt_details >= passing_percentage:
- result = "Passed"
+ if attempt_details.percentage >= passing_percentage:
+ result = "Pass"
else:
- result = attempt_details
+ result = attempt_details.status
return frappe._dict(
{
- "status": attempt_details,
+ "status": attempt_details.percentage
+ if assessment_type == "LMS Quiz"
+ else attempt_details.status,
"result": result,
+ "assessment": assessment,
+ "type": assessment_type,
+ "submission": attempt_details.name,
}
)
else:
diff --git a/lms/templates/emails/batch_confirmation.html b/lms/templates/emails/batch_confirmation.html
index b74d5a3d..4856ce39 100644
--- a/lms/templates/emails/batch_confirmation.html
+++ b/lms/templates/emails/batch_confirmation.html
@@ -6,12 +6,6 @@
{{ _("We are pleased to inform you that you have been enrolled in our upcoming batch. Congratulations!") }}
-
-
- {{ title }}
-
-
-
{{ _("Batch Start Date:") }} {{ frappe.utils.format_date(start_date, "medium") }}
@@ -27,7 +21,7 @@
{{ _("Visit the following link to view your ") }}
- {{ _("Batch Details") }}
+ {{ _("Batch Details") }}
{{ _("If you have any questions or require assistance, feel free to contact us.") }}
diff --git a/lms/templates/emails/payment_reminder.html b/lms/templates/emails/payment_reminder.html
index dd2847be..c7e70561 100644
--- a/lms/templates/emails/payment_reminder.html
+++ b/lms/templates/emails/payment_reminder.html
@@ -1,18 +1,24 @@
{{ _('Hi') }} {{ billing_name }},
+
{{ _('We noticed that you started enrolling in the') }} {{ type }} {{ title }} {{ _('but didn’t complete your payment') }}.
+
{{ _("We have a limited number of seats, and they won't be available for long!")}}
+
{{ _("Don’t miss this opportunity to enhance your skills. Click below to complete your enrollment") }}:
+
- 👉 Complete Your Enrollment
+ 👉 {{ _("Complete Your Enrollment") }}
+
{{ _("If you have any questions or need assistance, feel free to reach out to our support team.") }}
+
{{ __("Looking forward to seeing you enrolled!") }}
From 75cea1ab78fdfa9a16ebe06277a5f9f60e736890 Mon Sep 17 00:00:00 2001
From: Jannat Patel
Date: Thu, 13 Feb 2025 17:21:14 +0530
Subject: [PATCH 2/3] fix: delete unused custom fields from web form
---
lms/fixtures/custom_field.json | 504 ------------------
lms/patches.txt | 3 +-
.../v2_0/delete_unused_custom_fields.py | 13 +
3 files changed, 15 insertions(+), 505 deletions(-)
create mode 100644 lms/patches/v2_0/delete_unused_custom_fields.py
diff --git a/lms/fixtures/custom_field.json b/lms/fixtures/custom_field.json
index 67585780..74e660fa 100644
--- a/lms/fixtures/custom_field.json
+++ b/lms/fixtures/custom_field.json
@@ -951,62 +951,6 @@
"unique": 0,
"width": null
},
- {
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "collapsible_depends_on": null,
- "columns": 0,
- "default": null,
- "depends_on": null,
- "description": null,
- "docstatus": 0,
- "doctype": "Custom Field",
- "dt": "Web Form",
- "fetch_from": null,
- "fetch_if_empty": 0,
- "fieldname": "payments_tab",
- "fieldtype": "Tab Break",
- "hidden": 0,
- "hide_border": 0,
- "hide_days": 0,
- "hide_seconds": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_preview": 0,
- "in_standard_filter": 0,
- "insert_after": "custom_css",
- "is_system_generated": 1,
- "is_virtual": 0,
- "label": "Payments",
- "length": 0,
- "link_filters": null,
- "mandatory_depends_on": null,
- "modified": "2024-09-19 08:35:17.329032",
- "module": null,
- "name": "Web Form-payments_tab",
- "no_copy": 0,
- "non_negative": 0,
- "options": null,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "print_width": null,
- "read_only": 0,
- "read_only_depends_on": null,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "show_dashboard": 0,
- "sort_options": 0,
- "translatable": 0,
- "unique": 0,
- "width": null
- },
{
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
@@ -1119,230 +1063,6 @@
"unique": 0,
"width": null
},
- {
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "collapsible_depends_on": null,
- "columns": 0,
- "default": null,
- "depends_on": "accept_payment",
- "description": null,
- "docstatus": 0,
- "doctype": "Custom Field",
- "dt": "Web Form",
- "fetch_from": null,
- "fetch_if_empty": 0,
- "fieldname": "payment_gateway",
- "fieldtype": "Link",
- "hidden": 0,
- "hide_border": 0,
- "hide_days": 0,
- "hide_seconds": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_preview": 0,
- "in_standard_filter": 0,
- "insert_after": "accept_payment",
- "is_system_generated": 1,
- "is_virtual": 0,
- "label": "Payment Gateway",
- "length": 0,
- "link_filters": null,
- "mandatory_depends_on": null,
- "modified": "2024-09-19 08:35:17.408659",
- "module": null,
- "name": "Web Form-payment_gateway",
- "no_copy": 0,
- "non_negative": 0,
- "options": "Payment Gateway",
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "print_width": null,
- "read_only": 0,
- "read_only_depends_on": null,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "show_dashboard": 0,
- "sort_options": 0,
- "translatable": 0,
- "unique": 0,
- "width": null
- },
- {
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "collapsible_depends_on": null,
- "columns": 0,
- "default": "Buy Now",
- "depends_on": "accept_payment",
- "description": null,
- "docstatus": 0,
- "doctype": "Custom Field",
- "dt": "Web Form",
- "fetch_from": null,
- "fetch_if_empty": 0,
- "fieldname": "payment_button_label",
- "fieldtype": "Data",
- "hidden": 0,
- "hide_border": 0,
- "hide_days": 0,
- "hide_seconds": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_preview": 0,
- "in_standard_filter": 0,
- "insert_after": "payment_gateway",
- "is_system_generated": 1,
- "is_virtual": 0,
- "label": "Button Label",
- "length": 0,
- "link_filters": null,
- "mandatory_depends_on": null,
- "modified": "2024-09-19 08:35:17.439246",
- "module": null,
- "name": "Web Form-payment_button_label",
- "no_copy": 0,
- "non_negative": 0,
- "options": null,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "print_width": null,
- "read_only": 0,
- "read_only_depends_on": null,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "show_dashboard": 0,
- "sort_options": 0,
- "translatable": 0,
- "unique": 0,
- "width": null
- },
- {
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "collapsible_depends_on": null,
- "columns": 0,
- "default": null,
- "depends_on": null,
- "description": null,
- "docstatus": 0,
- "doctype": "Custom Field",
- "dt": "Web Form",
- "fetch_from": null,
- "fetch_if_empty": 0,
- "fieldname": "payments_cb",
- "fieldtype": "Column Break",
- "hidden": 0,
- "hide_border": 0,
- "hide_days": 0,
- "hide_seconds": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_preview": 0,
- "in_standard_filter": 0,
- "insert_after": "payment_button_help",
- "is_system_generated": 1,
- "is_virtual": 0,
- "label": null,
- "length": 0,
- "link_filters": null,
- "mandatory_depends_on": null,
- "modified": "2024-09-19 08:35:17.491696",
- "module": null,
- "name": "Web Form-payments_cb",
- "no_copy": 0,
- "non_negative": 0,
- "options": null,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "print_width": null,
- "read_only": 0,
- "read_only_depends_on": null,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "show_dashboard": 0,
- "sort_options": 0,
- "translatable": 0,
- "unique": 0,
- "width": null
- },
- {
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "collapsible_depends_on": null,
- "columns": 0,
- "default": null,
- "depends_on": "eval:doc.accept_payment && !doc.amount_based_on_field",
- "description": null,
- "docstatus": 0,
- "doctype": "Custom Field",
- "dt": "Web Form",
- "fetch_from": null,
- "fetch_if_empty": 0,
- "fieldname": "amount",
- "fieldtype": "Currency",
- "hidden": 0,
- "hide_border": 0,
- "hide_days": 0,
- "hide_seconds": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_preview": 0,
- "in_standard_filter": 0,
- "insert_after": "amount_field",
- "is_system_generated": 1,
- "is_virtual": 0,
- "label": "Amount",
- "length": 0,
- "link_filters": null,
- "mandatory_depends_on": null,
- "modified": "2024-09-19 08:35:17.569591",
- "module": null,
- "name": "Web Form-amount",
- "no_copy": 0,
- "non_negative": 0,
- "options": null,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "print_width": null,
- "read_only": 0,
- "read_only_depends_on": null,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "show_dashboard": 0,
- "sort_options": 0,
- "translatable": 0,
- "unique": 0,
- "width": null
- },
{
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
@@ -1399,174 +1119,6 @@
"unique": 0,
"width": null
},
- {
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "collapsible_depends_on": null,
- "columns": 0,
- "default": null,
- "depends_on": "accept_payment",
- "description": null,
- "docstatus": 0,
- "doctype": "Custom Field",
- "dt": "Web Form",
- "fetch_from": null,
- "fetch_if_empty": 0,
- "fieldname": "payment_button_help",
- "fieldtype": "Text",
- "hidden": 0,
- "hide_border": 0,
- "hide_days": 0,
- "hide_seconds": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_preview": 0,
- "in_standard_filter": 0,
- "insert_after": "payment_button_label",
- "is_system_generated": 1,
- "is_virtual": 0,
- "label": "Button Help",
- "length": 0,
- "link_filters": null,
- "mandatory_depends_on": null,
- "modified": "2024-09-19 08:35:17.466744",
- "module": null,
- "name": "Web Form-payment_button_help",
- "no_copy": 0,
- "non_negative": 0,
- "options": null,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "print_width": null,
- "read_only": 0,
- "read_only_depends_on": null,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "show_dashboard": 0,
- "sort_options": 0,
- "translatable": 0,
- "unique": 0,
- "width": null
- },
- {
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "collapsible_depends_on": null,
- "columns": 0,
- "default": "0",
- "depends_on": "accept_payment",
- "description": null,
- "docstatus": 0,
- "doctype": "Custom Field",
- "dt": "Web Form",
- "fetch_from": null,
- "fetch_if_empty": 0,
- "fieldname": "amount_based_on_field",
- "fieldtype": "Check",
- "hidden": 0,
- "hide_border": 0,
- "hide_days": 0,
- "hide_seconds": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_preview": 0,
- "in_standard_filter": 0,
- "insert_after": "payments_cb",
- "is_system_generated": 1,
- "is_virtual": 0,
- "label": "Amount Based On Field",
- "length": 0,
- "link_filters": null,
- "mandatory_depends_on": null,
- "modified": "2024-09-19 08:35:17.517344",
- "module": null,
- "name": "Web Form-amount_based_on_field",
- "no_copy": 0,
- "non_negative": 0,
- "options": null,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "print_width": null,
- "read_only": 0,
- "read_only_depends_on": null,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "show_dashboard": 0,
- "sort_options": 0,
- "translatable": 0,
- "unique": 0,
- "width": null
- },
- {
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "collapsible_depends_on": null,
- "columns": 0,
- "default": null,
- "depends_on": "eval:doc.accept_payment && doc.amount_based_on_field",
- "description": null,
- "docstatus": 0,
- "doctype": "Custom Field",
- "dt": "Web Form",
- "fetch_from": null,
- "fetch_if_empty": 0,
- "fieldname": "amount_field",
- "fieldtype": "Select",
- "hidden": 0,
- "hide_border": 0,
- "hide_days": 0,
- "hide_seconds": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_preview": 0,
- "in_standard_filter": 0,
- "insert_after": "amount_based_on_field",
- "is_system_generated": 1,
- "is_virtual": 0,
- "label": "Amount Field",
- "length": 0,
- "link_filters": null,
- "mandatory_depends_on": null,
- "modified": "2024-09-19 08:35:17.543136",
- "module": null,
- "name": "Web Form-amount_field",
- "no_copy": 0,
- "non_negative": 0,
- "options": null,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "print_width": null,
- "read_only": 0,
- "read_only_depends_on": null,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "show_dashboard": 0,
- "sort_options": 0,
- "translatable": 0,
- "unique": 0,
- "width": null
- },
{
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
@@ -1679,62 +1231,6 @@
"unique": 0,
"width": null
},
- {
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "collapsible_depends_on": null,
- "columns": 0,
- "default": null,
- "depends_on": "accept_payment",
- "description": null,
- "docstatus": 0,
- "doctype": "Custom Field",
- "dt": "Web Form",
- "fetch_from": null,
- "fetch_if_empty": 0,
- "fieldname": "currency",
- "fieldtype": "Link",
- "hidden": 0,
- "hide_border": 0,
- "hide_days": 0,
- "hide_seconds": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_preview": 0,
- "in_standard_filter": 0,
- "insert_after": "amount",
- "is_system_generated": 1,
- "is_virtual": 0,
- "label": "Currency",
- "length": 0,
- "link_filters": null,
- "mandatory_depends_on": null,
- "modified": "2024-09-19 08:35:17.595419",
- "module": null,
- "name": "Web Form-currency",
- "no_copy": 0,
- "non_negative": 0,
- "options": "Currency",
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "print_width": null,
- "read_only": 0,
- "read_only_depends_on": null,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "show_dashboard": 0,
- "sort_options": 0,
- "translatable": 0,
- "unique": 0,
- "width": null
- },
{
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
diff --git a/lms/patches.txt b/lms/patches.txt
index 2fd46b79..5dd122a8 100644
--- a/lms/patches.txt
+++ b/lms/patches.txt
@@ -99,4 +99,5 @@ lms.patches.v2_0.update_quiz_submission_data
lms.patches.v2_0.convert_quiz_duration_to_minutes
lms.patches.v2_0.allow_guest_access #05-02-2025
lms.patches.v2_0.migrate_batch_student_data #10-02-2025
-lms.patches.v2_0.delete_old_enrollment_doctypes
\ No newline at end of file
+lms.patches.v2_0.delete_old_enrollment_doctypes
+lms.patches.v2_0.delete_unused_custom_fields
\ No newline at end of file
diff --git a/lms/patches/v2_0/delete_unused_custom_fields.py b/lms/patches/v2_0/delete_unused_custom_fields.py
new file mode 100644
index 00000000..d49fe615
--- /dev/null
+++ b/lms/patches/v2_0/delete_unused_custom_fields.py
@@ -0,0 +1,13 @@
+import frappe
+
+def execute():
+ if "payments" not in frappe.get_installed_apps():
+ web_form_custom_fields = frappe.get_all("Custom Field", {
+ "dt": "Web Form"
+ }, ["name", "fieldname"])
+
+ unused_fields = ["currency", "amount_field", "amount_based_on_field", "payment_button_help", "amount", "payments_cb", "payment_button_label", "payment_gateway", "payments_tab"]
+
+ for field in web_form_custom_fields:
+ if field.fieldname in unused_fields:
+ frappe.delete_doc("Custom Field", field.name)
\ No newline at end of file
From 65f5b6a0a437d889045fc1c5986687439995e7c6 Mon Sep 17 00:00:00 2001
From: Jannat Patel
Date: Thu, 13 Feb 2025 17:23:57 +0530
Subject: [PATCH 3/3] fix: delete unused custom fields from web form
---
.../v2_0/delete_unused_custom_fields.py | 27 +++++++++++++------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/lms/patches/v2_0/delete_unused_custom_fields.py b/lms/patches/v2_0/delete_unused_custom_fields.py
index d49fe615..3fa6348d 100644
--- a/lms/patches/v2_0/delete_unused_custom_fields.py
+++ b/lms/patches/v2_0/delete_unused_custom_fields.py
@@ -1,13 +1,24 @@
import frappe
+
def execute():
- if "payments" not in frappe.get_installed_apps():
- web_form_custom_fields = frappe.get_all("Custom Field", {
- "dt": "Web Form"
- }, ["name", "fieldname"])
+ if "payments" not in frappe.get_installed_apps():
+ web_form_custom_fields = frappe.get_all(
+ "Custom Field", {"dt": "Web Form"}, ["name", "fieldname"]
+ )
- unused_fields = ["currency", "amount_field", "amount_based_on_field", "payment_button_help", "amount", "payments_cb", "payment_button_label", "payment_gateway", "payments_tab"]
+ unused_fields = [
+ "currency",
+ "amount_field",
+ "amount_based_on_field",
+ "payment_button_help",
+ "amount",
+ "payments_cb",
+ "payment_button_label",
+ "payment_gateway",
+ "payments_tab",
+ ]
- for field in web_form_custom_fields:
- if field.fieldname in unused_fields:
- frappe.delete_doc("Custom Field", field.name)
\ No newline at end of file
+ for field in web_form_custom_fields:
+ if field.fieldname in unused_fields:
+ frappe.delete_doc("Custom Field", field.name)