Opened 19 years ago

Closed 18 years ago

Last modified 18 years ago

#1077 closed defect (fixed)

BoundField class doesn't have "original_url" method, used in file widget in Admin

Reported by: Yango Owned by: Adrian Holovaty
Component: contrib.admin Version: dev
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Without the original_url method, the field widget of the admin app doesn't link to the file, as it calls the original_url method of the bound_field:

{% load admin_modify %}{% load i18n %}{% if bound_field.original_value %}
{% trans "Currently" %}: 

<a href="{{ bound_field.original_url }}" >

{{ bound_field.original_value }} </a><br />
{% trans "Change" %}: {% output_all bound_field.form_fields %}
{% else %} {% output_all bound_field.form_fields %} {% endif %}

(This isn't the exact version of current SVN, i added l10n to it, hugo- said he'd file a ticket about it)

So, I wrote this version of it:

    def original_url(self):
        if self.is_file_field and self.original and self.field.attname:
            url_method = getattr(self.original, 'get_%s_url' % self.field.attname)
            if callable(url_method):
                return url_method()
        return ''

And now the link is filled with the appropriate values (line 78 of core/meta/fields.py)

Change History (2)

comment:1 by rjwittams, 19 years ago

Added this method to AdminBoundField in magic-removal

comment:2 by Malcolm Tredinnick, 18 years ago

Resolution: fixed
Status: newclosed

Fixed as a result of magic-removal being merged into trunk.

Note: See TracTickets for help on using tickets.
Back to Top