Fix display format on SaaS & Sever admin list

mark_safe generated HTML
This commit is contained in:
Santiago L 2021-05-17 13:20:18 +02:00
parent a6c5aa32df
commit 3b4bb51925
2 changed files with 6 additions and 4 deletions

View file

@ -179,12 +179,12 @@ class ServerAdmin(ExtendedModelAdmin):
change_view_actions = actions
def display_ping(self, instance):
return self._remote_state[instance.pk][0]
return mark_safe(self._remote_state[instance.pk][0])
display_ping.short_description = _("Ping")
display_ping.allow_tags = True
def display_uptime(self, instance):
return self._remote_state[instance.pk][1]
return mark_safe(self._remote_state[instance.pk][1])
display_uptime.short_description = _("Uptime")
display_uptime.allow_tags = True

View file

@ -1,5 +1,6 @@
from django.contrib import admin
from django.core.exceptions import ObjectDoesNotExist
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from orchestra.admin import ExtendedModelAdmin, ChangePasswordAdminMixin
@ -26,7 +27,8 @@ class SaaSAdmin(SelectPluginAdminMixin, ChangePasswordAdminMixin, AccountAdminMi
plugin_field = 'service'
plugin_title = 'Software as a Service'
actions = (disable, enable, list_accounts)
@mark_safe
def display_url(self, saas):
site_domain = saas.get_site_domain()
site_link = '<a href="http://%s">%s</a>' % (site_domain, site_domain)
@ -48,7 +50,7 @@ class SaaSAdmin(SelectPluginAdminMixin, ChangePasswordAdminMixin, AccountAdminMi
display_url.short_description = _("URL")
display_url.allow_tags = True
display_url.admin_order_field = 'name'
def get_fields(self, *args, **kwargs):
fields = super(SaaSAdmin, self).get_fields(*args, **kwargs)
if not self.plugin_instance.allow_custom_url: