Ticket #6060: safe_widgets.diff

File safe_widgets.diff, 2.7 KB (added by Karen Tracey <kmtracey@…>, 17 years ago)
  • django/contrib/admin/widgets.py

     
    77from django.utils.text import capfirst
    88from django.utils.translation import ugettext as _
    99from django.conf import settings
     10from django.utils.safestring import mark_safe
    1011
    1112class FilteredSelectMultiple(forms.SelectMultiple):
    1213    """
     
    2829        # API to determine the ID dynamically.
    2930        output.append(u'SelectFilter.init("id_%s", "%s", %s, "%s"); });</script>\n' % \
    3031            (name, self.verbose_name.replace('"', '\\"'), int(self.is_stacked), settings.ADMIN_MEDIA_PREFIX))
    31         return u''.join(output)
     32        return mark_safe(''.join(output))
    3233
    3334class AdminDateWidget(forms.TextInput):
    3435    class Media:
     
    5758        forms.MultiWidget.__init__(self, widgets, attrs)
    5859
    5960    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]))
    6263
    6364class AdminFileWidget(forms.FileInput):
    6465    """
     
    7374        if value:
    7475            output.append('Currently: <a target="_blank" href="%s%s">%s</a> <br>Change: ' % (settings.MEDIA_URL, value, value))
    7576        output.append(super(AdminFileWidget, self).render(name, value, attrs))
    76         return u''.join(output)
     77        return mark_safe(u''.join(output))
    7778
    7879class ForeignKeyRawIdWidget(forms.TextInput):
    7980    """
     
    99100        output.append('<a href="%s%s" class="related-lookup" id="lookup_id_%s" onclick="return showRelatedObjectLookupPopup(this);"> ' % \
    100101            (related_url, url, name))
    101102        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))
    103104        #if self.change: # TODO
    104105            #output.append('&nbsp;<strong>TODO</strong>')
    105106           
     
    148149            output.append(u'<a href="%sadd/" class="add-another" id="add_id_%s" onclick="return showAddAnotherPopup(this);"> ' % \
    149150                (related_url, name))
    150151            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))
    152153
    153154    def __deepcopy__(self, memo):
    154155        # There's no reason to deepcopy admin_site, etc, so just return self.
Back to Top