Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Do not run plugin configuration in dashboard
Mira Szewczyk6e31f6e6806a
diff --git a/saleor/dashboard/payment/views.py b/saleor/dashboard/payment/views.pyindex 874eecb6b6..b6d996f5f0 100644--- a/saleor/dashboard/payment/views.py+++ b/saleor/dashboard/payment/views.py@@ -1,3 +1,5 @@+from typing import List+from django.contrib import messagesfrom django.contrib.auth.decorators import permission_requiredfrom django.http import Http404, HttpRequest, HttpResponse@@ -10,14 +12,23 @@ from ..views import staff_member_requiredfrom .forms import GatewayConfigurationForm+def list_payments_plugins(active_only: bool = False) -> List[str]:+ payment_method = "process_payment"+ extension_manager = get_extensions_manager()+ plugins = extension_manager.plugins+ if active_only:+ plugins = extension_manager.get_active_plugins()+ return [+ plugin.PLUGIN_NAME+ for plugin in plugins+ if payment_method in type(plugin).__dict__+ ]++@staff_member_required@permission_required("extensions.manage_plugins")def index(request: "HttpRequest") -> TemplateResponse:- payment_gateways = [- gateway["name"]- for gateway in get_extensions_manager().list_payment_gateways(active_only=False)- ]- ctx = {"payment_gateways": payment_gateways}+ ctx = {"payment_gateways": list_payments_plugins()}return TemplateResponse(request, "dashboard/payments/index.html", ctx)diff --git a/saleor/extensions/manager.py b/saleor/extensions/manager.pyindex ea367bde55..339a392eb6 100644--- a/saleor/extensions/manager.py+++ b/saleor/extensions/manager.py@@ -271,15 +271,20 @@ class ExtensionsManager(PaymentInterface):)raise Exception(f"Payment plugin {gateway} is inaccessible!")+ def get_active_plugins(self, plugins=None) -> List["BasePlugin"]:+ if plugins is None:+ plugins = self.plugins+ return [+ plugin+ for plugin in plugins+ if self.get_plugin_configuration(plugin.PLUGIN_NAME).active+ ]+def list_payment_gateways(self, active_only: bool = True) -> List[dict]:payment_method = "process_payment"plugins = self.pluginsif active_only:- plugins = [- plugin- for plugin in plugins- if self.get_plugin_configuration(plugin.PLUGIN_NAME).active- ]+ plugins = self.get_active_plugins()return [{"name": plugin.PLUGIN_NAME,