Code

Opened 8 years ago

Closed 8 years ago

Last modified 8 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
Component: contrib.admin Version: master
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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)

Attachments (0)

Change History (2)

comment:1 Changed 8 years ago by rjwittams

Added this method to AdminBoundField in magic-removal

comment:2 Changed 8 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.