Skip to content

Instantly share code, notes, and snippets.

@Arfey
Created March 2, 2017 12:05
Show Gist options
  • Save Arfey/db34ff30dbdc4a563a1815efc09e41a7 to your computer and use it in GitHub Desktop.
Save Arfey/db34ff30dbdc4a563a1815efc09e41a7 to your computer and use it in GitHub Desktop.
@admin.register(LogPsy)
class DefaultAdmin(admin.ModelAdmin):
list_display = ('id', 'date', 'anonymous_id', 'psy')
def psy(self, obj):
template = "<div style='border-bottom: 1px solid #ececec'>" \
" <b>%s</b>" \
" <span style='float: right'>%s&#37;</span><br/>" \
"</div>"
to_percent = lambda x: int(round(100 * x))
line = [template % (i.get('psy_name'), to_percent(i.get('probability'))) for i in obj.result]
return '<div>%s</div>' % "".join(line)
psy.allow_tags = True
psy.short_description = 'Психотипы'
@admin.register(LogManager)
class DefaultAdmin(admin.ModelAdmin):
list_display = ('id', 'date', 'manager')
def manager(self, obj):
template = "<div style='border-bottom: 1px solid #ececec'>" \
" <b>%s</b>" \
" <span style='float: right'>%s&#37;</span><br/>" \
"</div>"
to_percent = lambda x: int(round(100 * x))
line = [template % (i.get('manager_id'), to_percent(i.get('probability'))) for i in obj.result]
return '<div>%s</div>' % "".join(line)
manager.allow_tags = True
manager.short_description = 'Менеджери'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment