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

37 lines
953 B
Python
Raw Normal View History

2014-09-26 19:21:09 +00:00
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):
2014-09-26 21:24:23 +00:00
description_field = ''
2014-09-28 12:28:57 +00:00
form = None
2014-09-26 19:21:09 +00:00
serializer = None
2014-10-11 12:43:08 +00:00
icon = 'orchestra/icons/apps.png'
class_verbose_name = _("Software as a Service")
2014-09-26 19:21:09 +00:00
@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
2014-09-26 21:24:23 +00:00
self.form.plugin_field = 'service'
2014-09-26 19:21:09 +00:00
return self.form
def get_serializer(self):
self.serializer.plugin = self
return self.serializer
2014-09-26 21:24:23 +00:00
def get_description(self, data):
return data[self.description_field]