Ticket #6060: safe_widgets.diff
File safe_widgets.diff, 2.7 KB (added by , 17 years ago) |
---|
-
django/contrib/admin/widgets.py
7 7 from django.utils.text import capfirst 8 8 from django.utils.translation import ugettext as _ 9 9 from django.conf import settings 10 from django.utils.safestring import mark_safe 10 11 11 12 class FilteredSelectMultiple(forms.SelectMultiple): 12 13 """ … … 28 29 # API to determine the ID dynamically. 29 30 output.append(u'SelectFilter.init("id_%s", "%s", %s, "%s"); });</script>\n' % \ 30 31 (name, self.verbose_name.replace('"', '\\"'), int(self.is_stacked), settings.ADMIN_MEDIA_PREFIX)) 31 return u''.join(output)32 return mark_safe(''.join(output)) 32 33 33 34 class AdminDateWidget(forms.TextInput): 34 35 class Media: … … 57 58 forms.MultiWidget.__init__(self, widgets, attrs) 58 59 59 60 def format_output(self, rendered_widgets): 60 return u'<p class="datetime">%s %s<br />%s %s</p>' % \61 (_('Date:'), rendered_widgets[0], _('Time:'), rendered_widgets[1]) 61 return mark_safe(u'<p class="datetime">%s %s<br />%s %s</p>' % \ 62 (_('Date:'), rendered_widgets[0], _('Time:'), rendered_widgets[1])) 62 63 63 64 class AdminFileWidget(forms.FileInput): 64 65 """ … … 73 74 if value: 74 75 output.append('Currently: <a target="_blank" href="%s%s">%s</a> <br>Change: ' % (settings.MEDIA_URL, value, value)) 75 76 output.append(super(AdminFileWidget, self).render(name, value, attrs)) 76 return u''.join(output)77 return mark_safe(u''.join(output)) 77 78 78 79 class ForeignKeyRawIdWidget(forms.TextInput): 79 80 """ … … 99 100 output.append('<a href="%s%s" class="related-lookup" id="lookup_id_%s" onclick="return showRelatedObjectLookupPopup(this);"> ' % \ 100 101 (related_url, url, name)) 101 102 output.append('<img src="%simg/admin/selector-search.gif" width="16" height="16" alt="Lookup"></a>' % settings.ADMIN_MEDIA_PREFIX) 102 return u''.join(output)103 return mark_safe(u''.join(output)) 103 104 #if self.change: # TODO 104 105 #output.append(' <strong>TODO</strong>') 105 106 … … 148 149 output.append(u'<a href="%sadd/" class="add-another" id="add_id_%s" onclick="return showAddAnotherPopup(this);"> ' % \ 149 150 (related_url, name)) 150 151 output.append(u'<img src="%simg/admin/icon_addlink.gif" width="10" height="10" alt="Add Another"/></a>' % settings.ADMIN_MEDIA_PREFIX) 151 return u''.join(output)152 return mark_safe(u''.join(output)) 152 153 153 154 def __deepcopy__(self, memo): 154 155 # There's no reason to deepcopy admin_site, etc, so just return self.