Ticket #5695: 5695.diff

File 5695.diff, 1.4 KB (added by Marc Garcia, 17 years ago)

Improved patch

  • django/contrib/admin/widgets.py

     
    7272        from django.conf import settings
    7373        output = []
    7474        if value:
    75             output.append('Currently: <a target="_blank" href="%s%s">%s</a> <br>Change: ' % (settings.MEDIA_URL, value, value))
     75            output.append('%s: <a onclick="window.open(\'%s%s\'); return false" href="%s%s">%s</a><br/>%s: ' % (_('Currently'), settings.MEDIA_URL, value, settings.MEDIA_URL, value, value, _('Change')))
    7676        output.append(super(AdminFileWidget, self).render(name, value, attrs))
    7777        return mark_safe(u''.join(output))
    7878
  • dev/null

     
     1>>> from django.contrib.admin.widgets import AdminFileWidget
     2>>> w = AdminFileWidget()
     3>>> w.render('filename', '')
     4u'<input type="file" name="filename" />'
     5>>> w.render('filename', None)
     6u'<input type="file" name="filename" />'
     7>>> w.render('filename', '/media/file.ext')
     8u'Currently: <a onclick="window.open(\'//media/file.ext\'); return false" href="//media/file.ext">/media/file.ext</a><br/>Change: <input type="file" name="filename" />'
Back to Top