def network_icon(self, obj):
icons_url = staticfiles_storage.url('social_networks/img/admin_icons.svg')
try:
icon_code, icon_title = next((
network_tuple
for network_tuple in conf.ALL_NETWORKS
if network_tuple[0] == obj.network
))
except StopIteration:
return
offset = 100 / (len(SPRITE_ICONS) - 1) * SPRITE_ICONS.index(icon_code)
return """
<span style="display:inline-block; width:21px; height:20px; margin:0;
background:url(%s) %0.4f%% 0; vertical-align:middle;" title="%s"/>""" % (
icons_url, offset, icon_title
)
评论列表
文章目录