forked from CGM_Public/pretix_original
Payment providers: Add priority flag
This commit is contained in:
@@ -62,6 +62,8 @@ The provider class
|
|||||||
|
|
||||||
.. autoattribute:: is_enabled
|
.. autoattribute:: is_enabled
|
||||||
|
|
||||||
|
.. autoattribute:: priority
|
||||||
|
|
||||||
.. autoattribute:: settings_form_fields
|
.. autoattribute:: settings_form_fields
|
||||||
|
|
||||||
.. automethod:: settings_form_clean
|
.. automethod:: settings_form_clean
|
||||||
|
|||||||
@@ -632,7 +632,9 @@ class Event(EventMixin, LoggedModel):
|
|||||||
pp = p(self)
|
pp = p(self)
|
||||||
providers[pp.identifier] = pp
|
providers[pp.identifier] = pp
|
||||||
|
|
||||||
self._cached_payment_providers = OrderedDict(sorted(providers.items(), key=lambda v: str(v[1].verbose_name)))
|
self._cached_payment_providers = OrderedDict(sorted(
|
||||||
|
providers.items(), key=lambda v: (-v[1].priority, str(v[1].verbose_name))
|
||||||
|
))
|
||||||
return self._cached_payment_providers
|
return self._cached_payment_providers
|
||||||
|
|
||||||
def get_html_mail_renderer(self):
|
def get_html_mail_renderer(self):
|
||||||
|
|||||||
@@ -83,6 +83,14 @@ class BasePaymentProvider:
|
|||||||
"""
|
"""
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@property
|
||||||
|
def priority(self) -> int:
|
||||||
|
"""
|
||||||
|
Returns a priority that is used for sorting payment providers. Higher priority means higher up in the list.
|
||||||
|
Default to 100. Providers with same priority are sorted alphabetically.
|
||||||
|
"""
|
||||||
|
return 100
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_enabled(self) -> bool:
|
def is_enabled(self) -> bool:
|
||||||
"""
|
"""
|
||||||
@@ -925,6 +933,7 @@ class OffsettingProvider(BasePaymentProvider):
|
|||||||
class GiftCardPayment(BasePaymentProvider):
|
class GiftCardPayment(BasePaymentProvider):
|
||||||
identifier = "giftcard"
|
identifier = "giftcard"
|
||||||
verbose_name = _("Gift card")
|
verbose_name = _("Gift card")
|
||||||
|
priority = 10
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def settings_form_fields(self):
|
def settings_form_fields(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user