Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Move function to ExtensionManager
Mira Szewczyk54ed9aaf8f3b
diff --git a/saleor/dashboard/payment/views.py b/saleor/dashboard/payment/views.pyindex b6d996f5f0..1e3e99849d 100644--- a/saleor/dashboard/payment/views.py+++ b/saleor/dashboard/payment/views.py@@ -1,5 +1,3 @@-from typing import List-from django.contrib import messagesfrom django.contrib.auth.decorators import permission_requiredfrom django.http import Http404, HttpRequest, HttpResponse@@ -12,23 +10,10 @@ 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:- ctx = {"payment_gateways": list_payments_plugins()}+ ctx = {"payment_gateways": get_extensions_manager().list_payment_plugin_names()}return TemplateResponse(request, "dashboard/payments/index.html", ctx)diff --git a/saleor/extensions/manager.py b/saleor/extensions/manager.pyindex 339a392eb6..07d2f3b791 100644--- a/saleor/extensions/manager.py+++ b/saleor/extensions/manager.py@@ -280,20 +280,24 @@ class ExtensionsManager(PaymentInterface):if self.get_plugin_configuration(plugin.PLUGIN_NAME).active]- def list_payment_gateways(self, active_only: bool = True) -> List[dict]:+ def list_payment_plugin_names(self, active_only: bool = False) -> List[str]:payment_method = "process_payment"plugins = self.pluginsif active_only:plugins = self.get_active_plugins()return [- {- "name": plugin.PLUGIN_NAME,- "config": self.__get_payment_config(plugin.PLUGIN_NAME),- }+ plugin.PLUGIN_NAMEfor plugin in pluginsif payment_method in type(plugin).__dict__]+ def list_payment_gateways(self, active_only: bool = True) -> List[dict]:+ payment_plugins = self.list_payment_plugin_names(active_only=active_only)+ return [+ {"name": plugin_name, "config": self.__get_payment_config(plugin_name)}+ for plugin_name in payment_plugins+ ]+def get_payment_template(self, gateway: str) -> str:method_name = "get_payment_template"default_value = None