Exemplo n.º 1
0
 def admin_link(obj, attr=attribute):
     try: 
         url = get_field_value(obj, attr)
     except: 
         return ''
     link_url = "%s%s" % (base_url, url) if base_url else url
     return '<a href="%s">%s' % (link_url, url)
Exemplo n.º 2
0
 def admin_link(obj, attr=attribute):
     try:
         url = get_field_value(obj, attr)
     except:
         return ''
     link_url = "%s%s" % (base_url, url) if base_url else url
     return '<a href="%s">%s' % (link_url, url)
Exemplo n.º 3
0
 def colored_field(obj, field=field_name, colors=colours, verbose=verbose):
     value = escape(get_field_value(obj, field))
     color = colors.get(value, "black")
     if verbose:
         # Get the human-readable value of a choice field
         value = getattr(obj, 'get_%s_display' % field)()
     colored_value = '<span style="color: %s;">%s</span>' % (color, value)
     if bold:
         colored_value = '<b>%s</b>' % colored_value
     return mark_safe(colored_value)
Exemplo n.º 4
0
 def colored_field(obj, field=field_name, colors=colours, verbose=verbose):
     value = escape(get_field_value(obj, field))
     color = colors.get(value, "black")
     if verbose:
         # Get the human-readable value of a choice field
         value = getattr(obj, 'get_%s_display' % field)()
     colored_value = '<span style="color: %s;">%s</span>' % (color, value)
     if bold:
         colored_value = '<b>%s</b>' % colored_value
     return mark_safe(colored_value)
Exemplo n.º 5
0
 def link(obj, field=field_name, app_model=app_model, href_name=href_name):
     if field == '':
         rel = obj
     else:
         rel = get_field_value(obj, field)
     if not rel:
         return ''
     if not app_model:
         app_model = rel._meta.db_table
     url = reverse('admin:%s_change' % app_model, args=(rel.pk,))
     if not href_name:
         href_name = rel
     return mark_safe("<a href='%s'>%s</a>" % (url, href_name))
Exemplo n.º 6
0
 def link(obj, field=field_name, app_model=app_model, href_name=href_name):
     if field == '':
         rel = obj
     else:
         rel = get_field_value(obj, field)
     if not rel:
         return ''
     if not app_model:
         app_model = rel._meta.db_table
     url = reverse('admin:%s_change' % app_model, args=(rel.pk, ))
     if not href_name:
         href_name = rel
     return mark_safe("<a href='%s'>%s</a>" % (url, href_name))