From 5ae56347531a2a049d07619fab15557fa4bd24f8 Mon Sep 17 00:00:00 2001 From: raizasafeel <89463672+raizasafeel@users.noreply.github.com> Date: Mon, 2 Mar 2026 13:02:06 +0530 Subject: [PATCH] fix(payment gateway): add missing removeAccount function --- .../components/Settings/PaymentGateways.vue | 20 +++++++++++++++++++ lms/lms/api.py | 6 ++++++ 2 files changed, 26 insertions(+) diff --git a/frontend/src/components/Settings/PaymentGateways.vue b/frontend/src/components/Settings/PaymentGateways.vue index c1f2c809..a35b8344 100644 --- a/frontend/src/components/Settings/PaymentGateways.vue +++ b/frontend/src/components/Settings/PaymentGateways.vue @@ -88,6 +88,7 @@ import { Badge, Button, + call, createListResource, FeatherIcon, ListView, @@ -97,10 +98,12 @@ import { ListRow, ListRowItem, ListSelectBanner, + toast, } from 'frappe-ui' import { computed, ref } from 'vue' import { Plus, Trash2 } from 'lucide-vue-next' import PaymentGatewayDetails from '@/components/Settings/PaymentGatewayDetails.vue' +import { cleanError } from '@/utils' const showForm = ref(false) const currentGateway = ref(null) @@ -128,6 +131,23 @@ const openForm = (gatewayID) => { showForm.value = true } +const removeAccount = (selections, unselectAll) => { + call('lms.lms.api.delete_documents', { + doctype: 'Payment Gateway', + documents: Array.from(selections), + }) + .then(() => { + paymentGateways.reload() + toast.success(__('Payment gateways deleted successfully')) + unselectAll() + }) + .catch((err) => { + toast.error( + cleanError(err.messages[0]) || __('Error deleting payment gateways') + ) + }) +} + const columns = computed(() => { return [ { diff --git a/lms/lms/api.py b/lms/lms/api.py index 22cad460..5140bf60 100644 --- a/lms/lms/api.py +++ b/lms/lms/api.py @@ -702,7 +702,13 @@ def save_certificate_details( @frappe.whitelist() def delete_documents(doctype: str, documents: list): frappe.only_for("Moderator") + meta = frappe.get_meta(doctype) + non_lms_allowed = ["Payment Gateway", "Email Template"] + if meta.module != "LMS" and doctype not in non_lms_allowed: + frappe.throw(_("Deletion not allowed for {0}").format(doctype)) for doc in documents: + if not isinstance(doc, str) or not doc.strip(): + frappe.throw(_("Invalid document name")) frappe.delete_doc(doctype, doc)