django-orchestra/orchestra/contrib/saas/admin.py

30 lines
1.1 KiB
Python
Raw Normal View History

2014-09-26 19:21:09 +00:00
from django.contrib import admin
2015-04-04 17:44:07 +00:00
from django.utils.translation import ugettext_lazy as _
2014-09-26 19:21:09 +00:00
2015-04-02 16:14:55 +00:00
from orchestra.admin import ExtendedModelAdmin, ChangePasswordAdminMixin
2015-04-05 10:46:24 +00:00
from orchestra.contrib.accounts.admin import AccountAdminMixin
from orchestra.plugins.admin import SelectPluginAdminMixin
2014-09-26 19:21:09 +00:00
from .models import SaaS
from .services import SoftwareService
2015-04-02 16:14:55 +00:00
class SaaSAdmin(SelectPluginAdminMixin, ChangePasswordAdminMixin, AccountAdminMixin, ExtendedModelAdmin):
2015-03-25 17:04:44 +00:00
list_display = ('name', 'service', 'display_site_domain', 'account_link', 'is_active')
list_filter = ('service', 'is_active')
2015-04-07 15:14:49 +00:00
search_fields = ('name', 'account__username')
change_readonly_fields = ('service',)
2014-09-26 19:21:09 +00:00
plugin = SoftwareService
plugin_field = 'service'
2015-03-04 21:06:16 +00:00
plugin_title = 'Software as a Service'
2014-11-20 15:34:59 +00:00
def display_site_domain(self, saas):
site_domain = saas.get_site_domain()
return '<a href="http://%s">%s</a>' % (site_domain, site_domain)
display_site_domain.short_description = _("Site domain")
display_site_domain.allow_tags = True
display_site_domain.admin_order_field = 'name'
2015-03-04 21:06:16 +00:00
2014-09-26 19:21:09 +00:00
admin.site.register(SaaS, SaaSAdmin)