Ejemplo n.º 1
0
 def init(self):
     self.label = label_for_field(self.field_name,
                                  self.obj.__class__,
                                  model_admin=self.admin_view,
                                  return_attr=False)
     try:
         f, attr, value = lookup_field(self.field_name, self.obj,
                                       self.admin_view)
     except (AttributeError, ObjectDoesNotExist):
         self.text
     else:
         if f is None:
             self.allow_tags = getattr(attr, 'allow_tags', False)
             boolean = getattr(attr, 'boolean', False)
             if boolean:
                 self.allow_tags = True
                 self.text = boolean_icon(value)
             else:
                 self.text = smart_unicode(value)
         else:
             if isinstance(f.rel, models.ManyToOneRel):
                 self.text = getattr(self.obj, f.name)
             else:
                 self.text = display_for_field(value, f)
         self.field = f
         self.attr = attr
         self.value = value
Ejemplo n.º 2
0
 def init(self):
     self.label = label_for_field(self.field_name, self.obj.__class__,
                                  model_admin=self.admin_view,
                                  return_attr=False
                                  )
     try:
         f, attr, value = lookup_field(
             self.field_name, self.obj, self.admin_view)
     except (AttributeError, ObjectDoesNotExist):
         self.text
     else:
         if f is None:
             self.allow_tags = getattr(attr, 'allow_tags', False)
             boolean = getattr(attr, 'boolean', False)
             if boolean:
                 self.allow_tags = True
                 self.text = boolean_icon(value)
             else:
                 self.text = smart_unicode(value)
         else:
             if isinstance(f.rel, models.ManyToOneRel):
                 self.text = getattr(self.obj, f.name)
             else:
                 self.text = display_for_field(value, f)
         self.field = f
         self.attr = attr
         self.value = value
Ejemplo n.º 3
0
 def _get_new_field_html(self, field_name):
     try:
         f, attr, value = lookup_field(field_name, self.org_obj, self)
     except (AttributeError, ObjectDoesNotExist):
         return EMPTY_CHANGELIST_VALUE
     else:
         allow_tags = False
         if f is None:
             allow_tags = getattr(attr, 'allow_tags', False)
             boolean = getattr(attr, 'boolean', False)
             if boolean:
                 allow_tags = True
                 text = boolean_icon(value)
             else:
                 text = to_smart_unicode(value)
         else:
             if isinstance(f.rel, models.ManyToOneRel):
                 field_val = getattr(self.org_obj, f.name)
                 if field_val is None:
                     text = EMPTY_CHANGELIST_VALUE
                 else:
                     text = field_val
             else:
                 text = display_for_field(value, f)
         return mark_safe(text) if allow_tags else conditional_escape(text)
Ejemplo n.º 4
0
    def result_item(self, obj, field_name, row):
        """
        Generates the actual list of data.
        """
        item = ResultItem(field_name, row)
        try:
            f, attr, value = lookup_field(field_name, obj, self)
        except (AttributeError, ObjectDoesNotExist):
            item.text = mark_safe("<span class='muted'>%s</span>" %
                                  EMPTY_CHANGELIST_VALUE)
        else:
            if f is None:
                item.allow_tags = getattr(attr, 'allow_tags', False)
                boolean = getattr(attr, 'boolean', False)
                if boolean:
                    item.allow_tags = True
                    item.text = boolean_icon(value)
                else:
                    item.text = smart_unicode(value)
            else:
                if isinstance(f.rel, models.ManyToOneRel):
                    field_val = getattr(obj, f.name)
                    if field_val is None:
                        item.text = mark_safe("<span class='muted'>%s</span>" %
                                              EMPTY_CHANGELIST_VALUE)
                    else:
                        item.text = field_val
                else:
                    item.text = display_for_field(value, f)
                if isinstance(f, models.DateField)\
                    or isinstance(f, models.TimeField)\
                        or isinstance(f, models.ForeignKey):
                    item.classes.append('nowrap')

            item.field = f
            item.attr = attr
            item.value = value

        # If list_display_links not defined, add the link tag to the first field
        if (item.row['is_display_first'] and not self.list_display_links) \
                or field_name in self.list_display_links:
            item.row['is_display_first'] = False
            if self.list_display_links_details:
                opts = obj._meta
                item_res_uri = reverse('admin:%s_%s_detail' %
                                       (opts.app_label, opts.module_name),
                                       args=(getattr(obj, opts.pk.attname), ))
                if item_res_uri:
                    edit_url = reverse('admin:%s_%s_change' %
                                       (opts.app_label, opts.module_name),
                                       args=(getattr(obj, opts.pk.attname), ))
                    item.wraps.append(
                        '<a data-res-uri="%s" data-edit-uri="%s" class="details-handler" rel="tooltip" title="%s">%%s</a>'
                        % (item_res_uri, edit_url,
                           _(u'Details of %s') % str(obj)))
            else:
                url = self.url_for_result(obj)
                item.wraps.append(u'<a href="%s">%%s</a>' % url)

        return item
Ejemplo n.º 5
0
 def _get_new_field_html(self, field_name):
     try:
         f, attr, value = lookup_field(field_name, self.org_obj, self)
     except (AttributeError, ObjectDoesNotExist):
         return EMPTY_CHANGELIST_VALUE
     else:
         allow_tags = False
         if f is None:
             allow_tags = getattr(attr, 'allow_tags', False)
             boolean = getattr(attr, 'boolean', False)
             if boolean:
                 allow_tags = True
                 text = boolean_icon(value)
             else:
                 text = smart_unicode(value)
         else:
             if isinstance(f.rel, models.ManyToOneRel):
                 field_val = getattr(self.org_obj, f.name)
                 if field_val is None:
                     text = EMPTY_CHANGELIST_VALUE
                 else:
                     text = field_val
             else:
                 text = display_for_field(value, f)
         return mark_safe(text) if allow_tags else conditional_escape(text)
Ejemplo n.º 6
0
    def result_item(self, obj, field_name, row):
        """
        Generates the actual list of data.
        """
        item = ResultItem(field_name, row)
        try:
            f, attr, value = lookup_field(field_name, obj, self)
        except (AttributeError, ObjectDoesNotExist, NoReverseMatch):
            item.text = mark_safe("<span class='text-muted'>%s</span>" % EMPTY_CHANGELIST_VALUE)
        else:
            if f is None:
                item.allow_tags = getattr(attr, 'allow_tags', False)
                boolean = getattr(attr, 'boolean', False)
                if boolean:
                    item.allow_tags = True
                    item.text = boolean_icon(value)
                else:
                    item.text = smart_text(value)
            else:
                if isinstance(f.rel, models.ManyToOneRel):
                    field_val = getattr(obj, f.name)
                    if field_val is None:
                        item.text = mark_safe("<span class='text-muted'>%s</span>" % EMPTY_CHANGELIST_VALUE)
                    else:
                        item.text = field_val
                else:
                    item.text = display_for_field(value, f)
                if isinstance(f, models.DateField) \
                        or isinstance(f, models.TimeField) \
                        or isinstance(f, models.ForeignKey):
                    item.classes.append('nowrap')

            item.field = f
            item.attr = attr
            item.value = value

        # If list_display_links not defined, add the link tag to the first field
        if (item.row['is_display_first'] and not self.list_display_links) \
                or field_name in self.list_display_links:
            item.row['is_display_first'] = False
            item.is_display_link = True
            if self.list_display_links_details:
                item_res_uri = self.model_admin_url("detail", getattr(obj, self.pk_attname))
                if item_res_uri:
                    if self.has_change_permission(obj):
                        edit_url = self.model_admin_url("change", getattr(obj, self.pk_attname))
                    else:
                        edit_url = ""
                    item.wraps.append(
                        '<a data-res-uri="%s" data-edit-uri="%s" class="details-handler" rel="tooltip" title="%s">%%s</a>'
                        % (item_res_uri, edit_url, _(u'Details of %s') % str(obj)))
            else:
                url = self.url_for_result(obj)
                item.wraps.append(u'<a href="%s">%%s</a>' % url)

        return item
Ejemplo n.º 7
0
    def result_item(self, obj, field_name, row):
        """
        Generates the actual list of data.
        """
        item = ResultItem(field_name, row)
        try:
            f, attr, value = lookup_field(field_name, obj, self)
        except (AttributeError, ObjectDoesNotExist):
            item.text = EMPTY_CHANGELIST_VALUE
        else:
            if f is None:
                item.allow_tags = getattr(attr, 'allow_tags', False)
                boolean = getattr(attr, 'boolean', False)
                if boolean:
                    item.allow_tags = True
                    item.text = boolean_icon(value)
                else:
                    item.text = smart_unicode(value)
            else:
                if isinstance(f.rel, models.ManyToOneRel):
                    field_val = getattr(obj, f.name)
                    if field_val is None:
                        item.text = EMPTY_CHANGELIST_VALUE
                    else:
                        item.text = field_val
                else:
                    item.text = display_for_field(value, f)
                if isinstance(f, models.DateField)\
                    or isinstance(f, models.TimeField)\
                        or isinstance(f, models.ForeignKey):
                    item.classes.append('nowrap')

            item.field = f
            item.attr = attr
            item.value = value

        # If list_display_links not defined, add the link tag to the first field
        if (item.row['is_display_first'] and not self.list_display_links) \
                or field_name in self.list_display_links:
            url = self.url_for_result(obj)
            item.row['is_display_first'] = False
            item.wraps.append(u'<a href="%s">%%s</a>' % url)

        return item
Ejemplo n.º 8
0
    def result_item(self, obj, field_name, row):
        """
        Generates the actual list of data.
        """
        item = ResultItem(field_name, row)
        try:
            f, attr, value = lookup_field(field_name, obj, self)
        except (AttributeError, ObjectDoesNotExist):
            item.text = EMPTY_CHANGELIST_VALUE
        else:
            if f is None:
                item.allow_tags = getattr(attr, 'allow_tags', False)
                boolean = getattr(attr, 'boolean', False)
                if boolean:
                    item.allow_tags = True
                    item.text = boolean_icon(value)
                else:
                    item.text = smart_unicode(value)
            else:
                if isinstance(f.rel, models.ManyToOneRel):
                    field_val = getattr(obj, f.name)
                    if field_val is None:
                        item.text = EMPTY_CHANGELIST_VALUE
                    else:
                        item.text = field_val
                else:
                    item.text = display_for_field(value, f)
                if isinstance(f, models.DateField)\
                    or isinstance(f, models.TimeField)\
                        or isinstance(f, models.ForeignKey):
                    item.classes.append('nowrap')

            item.field = f
            item.attr = attr
            item.value = value

        # If list_display_links not defined, add the link tag to the first field
        if (item.row['is_display_first'] and not self.list_display_links) \
                or field_name in self.list_display_links:
            url = self.url_for_result(obj)
            item.row['is_display_first'] = False
            item.wraps.append(u'<a href="%s">%%s</a>' % url)

        return item
Ejemplo n.º 9
0
    def init(self):
        self.label = label_for_field(self.field_name, self.obj.__class__,
                                     model_admin=self.admin_view,
                                     return_attr=False
                                     )
        try:
            f, attr, value = lookup_field(
                self.field_name, self.obj, self.admin_view)
        except (AttributeError, ObjectDoesNotExist):
            self.text
        else:
            if f is None:
                self.allow_tags = getattr(attr, 'allow_tags', False)
                boolean = getattr(attr, 'boolean', False)
                decimal = getattr(attr, 'decimal', None)

                if boolean:
                    self.allow_tags = True
                    self.text = boolean_icon(value)

                elif decimal and value is not None:
                    # removing trailing zeros after .
                    from django.utils import formats

                    value = str(value)
                    if value.rfind('.') != -1:
                        value = value.rstrip('0')
                        decimal_places = len(value) - value.index('.') - 1
                    else:
                        decimal_places = 0

                    # show value by format settings
                    self.text = formats.number_format(value, decimal_places)

                else:
                    self.text = smart_text(value)
            else:
                if isinstance(f.rel, models.ManyToOneRel):
                    self.text = getattr(self.obj, f.name)
                else:
                    self.text = display_for_field(value, f)
            self.field = f
            self.attr = attr
            self.value = value
Ejemplo n.º 10
0
    def result_item(self, obj, field_name, row):
        """
        返回某一对象某一列的数据, :class:`ResultItem` 实例.

        :param obj: Model 对象
        :param field_name: 列的名字
        :param row: :class:`ResultHeader` 实例
        """
        item = ResultItem(field_name, row) # 首先初始化
        field_name_split = field_name.split('.')
        field_name = field_name_split[0]
        try:
            f, attr, value = lookup_field(field_name, obj, self)
        except (AttributeError, ObjectDoesNotExist):
            item.text = mark_safe("<span class='text-muted'>%s</span>" % EMPTY_CHANGELIST_VALUE)
        else:
            if f is None:
                # Model 属性或是 OptionClass 属性列
                item.allow_tags = getattr(attr, 'allow_tags', False)
                boolean = getattr(attr, 'boolean', False)
                if boolean:
                    item.allow_tags = True
                    item.text = boolean_icon(value)
                else:
                    item.text = smart_unicode(value)
            else:
                # 处理关联咧
                if isinstance(f.rel, models.ManyToOneRel):
                    field_val = getattr(obj, f.name)
                    if field_val is None:
                        item.text = mark_safe("<span class='text-muted'>%s</span>" % EMPTY_CHANGELIST_VALUE)
                    else:
                        if len(field_name_split)>1:
                            item.text = getattr(field_val,field_name_split[1])
                        else:
                            item.text = field_val
                else:
                    item.text = display_for_field(value, f)
                if isinstance(f, models.DateField)\
                    or isinstance(f, models.TimeField)\
                        or isinstance(f, models.ForeignKey):
                    item.classes.append('nowrap')

            item.field = f
            item.attr = attr
            item.value = value

        # 如果没有指定 ``list_display_links`` , 使用第一列作为内容连接列.
        if (item.row['is_display_first'] and not self.list_display_links) \
                or field_name in self.list_display_links:
            item.row['is_display_first'] = False
            item.is_display_link = True
            if self.list_display_links_details:
                item_res_uri = self.model_admin_url("detail", getattr(obj, self.pk_name))
                if item_res_uri:
                    edit_url = self.model_admin_url("change", getattr(obj, self.pk_name))
                    item.wraps.append('<a data-res-uri="%s" data-edit-uri="%s" class="details-handler" rel="tooltip" title="%s">%%s</a>'
                                     % (item_res_uri, edit_url, _(u'Details of %s') % str(obj)))
            else:
                url = self.get_object_url(obj)
                if self.pop:
                    if 's' in self.request.GET:
                        show = getattr(obj, self.request.GET.get('s'))
                        if callable(show):show = show()
                    else:
                        show = escape(Truncator(obj).words(14, truncate='...'))
                    show = str(show).replace('%','%%').replace("\'","\\\'")
                    pop = format_html(' class="for_multi_select" show="{0}" sid="{1}" ', show, getattr(obj, self.request.GET.get('t')) )
                else:
                    pop = ''
                item.wraps.append(u'<a href="%s" %s>%%s</a>' % (url, pop))

        return item
Ejemplo n.º 11
0
    def result_item(self, obj, field_name, row):
        """
        Generates the actual list of data.
        """
        item = ResultItem(field_name, row)
        try:
            f, attr, value = lookup_field(field_name, obj, self)
        except (AttributeError, ObjectDoesNotExist, NoReverseMatch):
            item.text = mark_safe("<span class='text-muted'>%s</span>" % EMPTY_CHANGELIST_VALUE)
        else:
            if f is None:
                item.allow_tags = getattr(attr, 'allow_tags', False)
                boolean = getattr(attr, 'boolean', False)
                decimal = getattr(attr, 'decimal', None)

                if boolean:
                    item.allow_tags = True
                    item.text = boolean_icon(value)

                elif decimal and value is not None:
                    # removing trailing zeros after .
                    from django.utils import formats

                    value = str(value)
                    if value.rfind('.') != -1:
                        value = value.rstrip('0')
                        decimal_places = len(value) - value.index('.') - 1
                    else:
                        decimal_places = 0

                    # show value by format settings
                    item.text = formats.number_format(value, decimal_places)

                else:
                    item.text = smart_text(value)
            else:
                if isinstance(f.rel, models.ManyToOneRel):
                    field_val = getattr(obj, f.name)
                    if field_val is None:
                        item.text = mark_safe("<span class='text-muted'>%s</span>" % EMPTY_CHANGELIST_VALUE)
                    else:
                        item.text = field_val
                else:
                    item.text = display_for_field(value, f)
                    if item.text == EMPTY_CHANGELIST_VALUE:
                        # makes null value also in grey for non-rel fields
                        item.text = mark_safe("<span class='text-muted'>%s</span>" % EMPTY_CHANGELIST_VALUE)

                if isinstance(f, models.DateField)\
                    or isinstance(f, models.TimeField)\
                        or isinstance(f, models.ForeignKey):
                    item.classes.append('nowrap')

            if item.text and field_name in getattr(self, 'align_right_fields', []):
                item.text = mark_safe("<div class='pull-right'>%s</div>" % item.text)

            item.field = f
            item.attr = attr
            item.value = value

        # If list_display_links not defined, add the link tag to the first field
        if self.list_display_links is not None and\
                ((item.row['is_display_first'] and self.list_display_links == ()) or field_name in self.list_display_links):
            item.row['is_display_first'] = False
            item.is_display_link = True
            if self.list_display_links_details:
                item_res_uri = self.model_admin_url("detail", getattr(obj, self.pk_attname))
                if item_res_uri:
                    if self.has_change_permission(obj):
                        edit_url = self.model_admin_url("change", getattr(obj, self.pk_attname))
                    else:
                        edit_url = ""
                    item.wraps.append('<a data-res-uri="%s" data-edit-uri="%s" class="details-handler" rel="tooltip" title="%s">%%s</a>'
                                     % (item_res_uri, edit_url, _(u'Details of %s') % str(obj)))
            else:
                url = self.url_for_result(obj)
                item.wraps.append(u'<a href="%s">%%s</a>' % url)

        return item
Ejemplo n.º 12
0
    def result_item(self, obj, field_name, row):
        """
        Generates the actual list of data.
        """
        item = ResultItem(field_name, row)
        try:
            f, attr, value = lookup_field(field_name, obj, self)
        except (AttributeError, ObjectDoesNotExist, NoReverseMatch):
            item.text = mark_safe("<span class='text-muted'>%s</span>" %
                                  EMPTY_CHANGELIST_VALUE)
        else:
            if f is None:
                item.allow_tags = getattr(attr, "allow_tags", False)
                boolean = getattr(attr, "boolean", False)
                if boolean:
                    item.allow_tags = True
                    item.text = boolean_icon(value)
                else:
                    item.text = smart_text(value)
            else:
                if isinstance(f.rel, models.ManyToOneRel):
                    field_val = getattr(obj, f.name)
                    if field_val is None:
                        item.text = mark_safe(
                            "<span class='text-muted'>%s</span>" %
                            EMPTY_CHANGELIST_VALUE)
                    else:
                        item.text = field_val
                else:
                    item.text = display_for_field(value, f)
                if (isinstance(f, models.DateField)
                        or isinstance(f, models.TimeField)
                        or isinstance(f, models.ForeignKey)):
                    item.classes.append("nowrap")

            item.field = f
            item.attr = attr
            item.value = value

        # If list_display_links not defined, add the link tag to the first field
        if (item.row["is_display_first"] and not self.list_display_links
            ) or field_name in self.list_display_links:
            item.row["is_display_first"] = False
            item.is_display_link = True
            if self.list_display_links_details:
                item_res_uri = self.model_admin_url(
                    "detail", getattr(obj, self.pk_attname))
                if item_res_uri:
                    if self.has_change_permission(obj):
                        edit_url = self.model_admin_url(
                            "change", getattr(obj, self.pk_attname))
                    else:
                        edit_url = ""
                    item.wraps.append(
                        '<a data-res-uri="%s" data-edit-uri="%s" class="details-handler" rel="tooltip" title="%s">%%s</a>'
                        % (item_res_uri, edit_url,
                           _(u"Details of %s") % str(obj)))
            else:
                url = self.url_for_result(obj)
                item.wraps.append(u'<a href="%s">%%s</a>' % url)

        return item
Ejemplo n.º 13
0
    def result_item(self, obj, field_name, row):
        """
        Generates the actual list of data.
        """
        item = ResultItem(field_name, row)
        try:
            f, attr, value = lookup_field(field_name, obj, self)
        except (AttributeError, ObjectDoesNotExist, NoReverseMatch):
            item.text = mark_safe("<span class='text-muted'>%s</span>" %
                                  EMPTY_CHANGELIST_VALUE)
        else:
            if f is None:
                item.allow_tags = getattr(attr, 'allow_tags', False)
                boolean = getattr(attr, 'boolean', False)
                if boolean:
                    item.allow_tags = True
                    item.text = boolean_icon(value)
                else:
                    item.text = smart_text(value)
            else:
                if isinstance(f.remote_field, models.ManyToOneRel):
                    field_val = getattr(obj, f.name)
                    if field_val is None:
                        item.text = mark_safe(
                            "<span class='text-muted'>%s</span>" %
                            EMPTY_CHANGELIST_VALUE)
                    else:
                        item.text = field_val
                elif isinstance(f, models.ImageField):
                    '''
                    调整框架代码,如果是imgafiel在列表中会显示图片而非连接
                    '''
                    field_val = getattr(obj, f.name)
                    if field_val is not None and field_val.name is not None:
                        url = field_val.url
                        if 'http://' in str(field_val) or 'https://' in str(
                                field_val):
                            url = str(field_val)

                        item.text = mark_safe(
                            '<a href="%s" target="_blank" title="点击查看大图" data-gallery="gallery"><img src="%s" class="field_img"/></a>'
                            % (url, url))
                    else:
                        item.text = '无'
                else:
                    item.text = display_for_field(value, f)
                if isinstance(f, models.DateField)\
                    or isinstance(f, models.TimeField)\
                        or isinstance(f, models.ForeignKey):
                    item.classes.append('nowrap')

            item.field = f
            item.attr = attr
            item.value = value

        # If list_display_links not defined, add the link tag to the first field
        if (item.row['is_display_first'] and not self.list_display_links) \
                or field_name in self.list_display_links:
            item.row['is_display_first'] = False
            item.is_display_link = True
            if self.list_display_links_details:
                item_res_uri = self.model_admin_url(
                    "detail", getattr(obj, self.pk_attname))
                if item_res_uri:
                    if self.has_change_permission(obj):
                        edit_url = self.model_admin_url(
                            "change", getattr(obj, self.pk_attname))
                    else:
                        edit_url = ""
                    item.wraps.append(
                        '<a data-res-uri="%s" data-edit-uri="%s" class="details-handler" rel="tooltip" title="%s">%%s</a>'
                        % (item_res_uri, edit_url,
                           _(u'Details of %s') % str(obj)))
            else:
                url = self.url_for_result(obj)
                item.wraps.append(u'<a href="%s">%%s</a>' % url)

        return item
Ejemplo n.º 14
0
    def result_item(self, obj, field_name, row):
        """
        返回某一对象某一列的数据, :class:`ResultItem` 实例.

        :param obj: Model 对象
        :param field_name: 列的名字
        :param row: :class:`ResultHeader` 实例
        """

        item = ResultItem(field_name, row)  # 首先初始化
        try:
            f, attr, value = lookup_field(field_name, obj, self)
        except (AttributeError, ObjectDoesNotExist, NoReverseMatch):
            item.text = mark_safe("<span class='text-muted'>%s</span>" %
                                  EMPTY_CHANGELIST_VALUE)
        else:
            if f is None:
                # Model 属性或是 OptionClass 属性列
                item.allow_tags = getattr(attr, 'allow_tags', False)
                boolean = getattr(attr, 'boolean', False)
                if boolean:
                    item.allow_tags = True
                    item.text = boolean_icon(value)
                else:
                    item.text = smart_text(value)
            else:
                # 处理关联咧
                if isinstance(f.remote_field, models.ManyToOneRel):
                    field_val = getattr(obj, f.name)
                    if field_val is None:
                        item.text = mark_safe(
                            "<span class='text-muted'>%s</span>" %
                            EMPTY_CHANGELIST_VALUE)
                    else:
                        item.text = field_val
                else:
                    item.text = display_for_field(value, f)
                if isinstance(f, models.DateField) \
                        or isinstance(f, models.TimeField) \
                        or isinstance(f, models.ForeignKey):
                    item.classes.append('nowrap')

            item.field = f
            item.attr = attr
            item.value = value

        # 如果没有指定 ``list_display_links`` , 使用第一列作为内容连接列.
        if (item.row['is_display_first'] and not self.list_display_links) \
                or field_name in self.list_display_links:
            item.row['is_display_first'] = False
            item.is_display_link = True
            if self.list_display_links_details:
                item_res_uri = self.model_admin_url(
                    "detail", getattr(obj, self.pk_attname))
                if item_res_uri:
                    if self.has_change_permission(obj):
                        edit_url = self.model_admin_url(
                            "change", getattr(obj, self.pk_attname))
                    else:
                        edit_url = ""
                    item.wraps.append(
                        '<a data-res-uri="%s" data-edit-uri="%s" class="details-handler" rel="tooltip" title="%s">%%s</a>'
                        % (item_res_uri, edit_url,
                           _(u'Details of %s') % str(obj)))
            else:
                url = self.url_for_result(obj)
                item.wraps.append(u'<a href="%s">%%s</a>' % url)

        return item