# -*- coding: utf-8 -*-

from django.contrib import admin
from app.models import Usuario,Asignatura

class UsuarioAdmin(admin.ModelAdmin):
    list_display = ('user','upper_case_name','bio','get_foto')
    search_field = ('user',)

    def upper_case_name(self, obj):
        return '<span style="color: red;">%s</span>' % (obj.nombre).upper()
    upper_case_name.short_description = 'Nombre'
    upper_case_name.allow_tags = True

    def get_foto(self,obj):
        if obj.foto:
            return """<a href="/media/%s"><img src="/media/%s" alt="" heigth="100px" width="100px"/></a>"""%(obj.foto,obj.foto)
        else:
            return '(Sin imagen)'
    get_foto.short_description = 'Thumbnails'
    get_foto.allow_tags = True


admin.site.register(Usuario,UsuarioAdmin)
admin.site.register(Asignatura)