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)