django-orchestra/orchestra/apps/saas/services/options.py

35 lines
863 B
Python

from django import forms
from django.utils.translation import ugettext_lazy as _
from orchestra.utils import plugins
from orchestra.utils.functional import cached
from orchestra.utils.python import import_class
from .. import settings
class SoftwareService(plugins.Plugin):
description_field = ''
form = None
serializer = None
@classmethod
@cached
def get_plugins(cls):
plugins = []
for cls in settings.SAAS_ENABLED_SERVICES:
plugins.append(import_class(cls))
return plugins
def get_form(self):
self.form.plugin = self
self.form.plugin_field = 'service'
return self.form
def get_serializer(self):
self.serializer.plugin = self
return self.serializer
def get_description(self, data):
return data[self.description_field]