#5767: Patch for EmailField to render as a mailto anchor in admin interface
---------------------------+------------------------------------------------
Reporter:  hax             |       Owner:  nobody         
  Status:  new             |   Component:  Admin interface
 Version:  newforms-admin  |    Keywords:  EmailField     
   Stage:  Unreviewed      |   Has_patch:  1              
---------------------------+------------------------------------------------
 It seems to me that there is no reason to not have an EmailField be a
 mailto link in an admin interface.  These interfaces generally aren't
 public, so hiding from spambots shouldn't be an issue.

 This is my first attempt at a patch, feedback is appreciated :)

 {{{
 Index: django/contrib/admin/templatetags/admin_list.py
 ===================================================================
 --- django/contrib/admin/templatetags/admin_list.py     (revision 6525)
 +++ django/contrib/admin/templatetags/admin_list.py     (working copy)
 @@ -177,6 +177,12 @@
                      result_repr = ('%%.%sf' % f.decimal_places) %
 field_val
                  else:
                      result_repr = EMPTY_CHANGELIST_VALUE
 +            # EmailFields are mailto links
 +            elif isinstance(f, models.EmailField):
 +                if field_val is not None:
 +                    result_repr = '<a href="mailto:%s";>%s</a>' %
 (escape(field_val), escape(field_val))
 +                else:
 +                    result_repr = EMPTY_CHANGELIST_VALUE
              # Fields with choices are special: Use the representation
              # of the choice.
              elif f.choices:

 }}}


 --maqr

-- 
Ticket URL: <http://code.djangoproject.com/ticket/5767>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to