django-orchestra-test/orchestra/contrib/payments/methods/options.py

43 lines
1.2 KiB
Python
Raw Permalink Normal View History

2016-02-09 12:17:42 +00:00
import importlib
2015-05-04 14:19:58 +00:00
import logging
2016-02-09 12:17:42 +00:00
import os
from dateutil import relativedelta
from functools import lru_cache
from orchestra import plugins
2014-09-16 15:01:02 +00:00
from orchestra.utils.python import import_class
from .. import settings
2016-02-09 12:17:42 +00:00
class PaymentMethod(plugins.Plugin, metaclass=plugins.PluginMount):
label_field = 'label'
number_field = 'number'
allow_recharge = False
due_delta = relativedelta.relativedelta(months=1)
2015-03-23 15:36:51 +00:00
plugin_field = 'method'
2015-09-29 12:35:22 +00:00
state_help = {}
2014-09-16 15:01:02 +00:00
@classmethod
@lru_cache()
2016-02-09 12:17:42 +00:00
def get_plugins(cls, all=False):
if all:
for module in os.listdir(os.path.dirname(__file__)):
if module not in ('options.py', '__init__.py') and module[-3:] == '.py':
importlib.import_module('.'+module[:-3], __package__)
plugins = super().get_plugins()
else:
plugins = []
for cls in settings.PAYMENTS_ENABLED_METHODS:
plugins.append(import_class(cls))
2014-09-16 15:01:02 +00:00
return plugins
def get_label(self):
return self.instance.data[self.label_field]
def get_number(self):
return self.instance.data[self.number_field]
def get_bill_message(self):
2014-09-10 16:53:09 +00:00
return ''