2013-05-23 17:46:03 +00:00
|
|
|
def model_options(model):
|
|
|
|
|
"""
|
|
|
|
|
Wrapper for accessing model._meta. If this access point changes in core
|
|
|
|
|
Django, this function allows django-admin2 to address the change with
|
|
|
|
|
what should hopefully be less disruption to the rest of the code base.
|
2013-05-24 14:22:54 +00:00
|
|
|
|
|
|
|
|
Works on model classes and objects.
|
2013-05-23 17:46:03 +00:00
|
|
|
"""
|
|
|
|
|
return model._meta
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def admin2_urlname(view, action):
|
|
|
|
|
"""
|
|
|
|
|
Converts the view and the specified action into a valid namespaced URLConf name.
|
|
|
|
|
"""
|
|
|
|
|
return 'admin2:%s_%s_%s' % (view.app_label, view.model_name, action)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def model_verbose_name(obj):
|
|
|
|
|
"""
|
|
|
|
|
Returns the verbose name of a model instance or class.
|
|
|
|
|
"""
|
|
|
|
|
return model_options(obj).verbose_name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def model_verbose_name_plural(obj):
|
|
|
|
|
"""
|
|
|
|
|
Returns the pluralized verbose name of a model instance or class.
|
|
|
|
|
"""
|
|
|
|
|
return model_options(obj).verbose_name_plural
|
2013-05-26 00:55:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def model_app_label(obj):
|
|
|
|
|
"""
|
|
|
|
|
Returns the app label of a model instance or class.
|
|
|
|
|
"""
|
|
|
|
|
return model_options(obj).app_label
|