Add support for classes
This commit is contained in:
@@ -5,6 +5,8 @@ from django.forms.util import flatatt
|
||||
from django.utils.html import conditional_escape
|
||||
from django.utils.encoding import force_unicode
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.db.models.base import ModelBase
|
||||
from django.template.defaultfilters import capfirst
|
||||
|
||||
from acls.literals import CONTENT_TYPE_ICON_MAP
|
||||
|
||||
@@ -14,13 +16,15 @@ def content_type_icon(content_type):
|
||||
|
||||
|
||||
def object_w_content_type_icon(obj):
|
||||
content_type = ContentType.objects.get_for_model(obj)
|
||||
|
||||
ct_fullname = '%s.%s' % (content_type.app_label, content_type.name)
|
||||
|
||||
if ct_fullname == 'auth.user':
|
||||
label = obj.get_full_name()
|
||||
else:
|
||||
label = unicode(obj)
|
||||
|
||||
return mark_safe('%s<span>%s</span>' % (content_type_icon(content_type), label))
|
||||
content_type = ContentType.objects.get_for_model(obj)
|
||||
|
||||
ct_fullname = '%s.%s' % (content_type.app_label, content_type.name)
|
||||
if isinstance(obj, ModelBase):
|
||||
label = getattr(obj._meta, 'verbose_name_plural', unicode(content_type))
|
||||
else:
|
||||
if ct_fullname == 'auth.user':
|
||||
label = obj.get_full_name()
|
||||
else:
|
||||
label = unicode(obj)
|
||||
|
||||
return mark_safe('%s<span>%s</span>' % (content_type_icon(content_type), capfirst(label)))
|
||||
|
||||
Reference in New Issue
Block a user