From 06c226d302812d856c9cf81af743de94260b5bd5 Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Fri, 21 May 2021 11:17:06 +0200 Subject: [PATCH] Handle HTML safe rendering on webapps & miscellaneous Drop `allow_tags` attribute which has been removed on Django 2.0 --- orchestra/contrib/miscellaneous/admin.py | 7 +++---- orchestra/contrib/webapps/admin.py | 17 +---------------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/orchestra/contrib/miscellaneous/admin.py b/orchestra/contrib/miscellaneous/admin.py index 2f7d699c..ff4920e6 100644 --- a/orchestra/contrib/miscellaneous/admin.py +++ b/orchestra/contrib/miscellaneous/admin.py @@ -2,6 +2,7 @@ from django import forms from django.contrib import admin from django.urls import reverse from django.db import models +from django.utils.html import format_html from django.utils.safestring import mark_safe from django.utils.translation import ugettext_lazy as _ @@ -38,15 +39,13 @@ class MiscServiceAdmin(ExtendedModelAdmin): actions = (disable, enable) def display_name(self, misc): - return '%s' % (misc.description, misc.name) + return format_html('{}', misc.description, misc.name) display_name.short_description = _("name") - display_name.allow_tags = True display_name.admin_order_field = 'name' def display_verbose_name(self, misc): - return '%s' % (misc.description, misc.verbose_name) + return format_html('{}', misc.description, misc.verbose_name) display_verbose_name.short_description = _("verbose name") - display_verbose_name.allow_tags = True display_verbose_name.admin_order_field = 'verbose_name' def num_instances(self, misc): diff --git a/orchestra/contrib/webapps/admin.py b/orchestra/contrib/webapps/admin.py index 12cacb2c..29247079 100644 --- a/orchestra/contrib/webapps/admin.py +++ b/orchestra/contrib/webapps/admin.py @@ -89,23 +89,8 @@ class WebAppAdmin(SelectPluginAdminMixin, AccountAdminMixin, ExtendedModelAdmin) try: return webapp.type_instance.get_detail() except KeyError: - return "Not available" + return mark_safe("Not available") display_detail.short_description = _("detail") - display_detail.allow_tags = True -# def get_form(self, request, obj=None, **kwargs): -# form = super(WebAppAdmin, self).get_form(request, obj, **kwargs) -# if obj: -# - -# def formfield_for_dbfield(self, db_field, **kwargs): -# """ Make value input widget bigger """ -# if db_field.name == 'type': -# # Help text based on select widget -# kwargs['widget'] = DynamicHelpTextSelect( -# 'this.id.replace("name", "value")', self.TYPE_HELP_TEXT -# ) -# kwargs['help_text'] = self.TYPE_HELP_TEXT.get(db_field.default, '') -# return super(WebAppAdmin, self).formfield_for_dbfield(db_field, **kwargs) admin.site.register(WebApp, WebAppAdmin)