mirror of
https://github.com/jazzband/django-admin2.git
synced 2026-03-19 15:40:30 +00:00
There's currently a lot of copy-pasting of breadcrumbs, this can be revisited once we have a better understanding of how we're going to handle navigation. I've also tried to make template context variables more logical and consistent throughout.
37 lines
No EOL
1,007 B
Python
37 lines
No EOL
1,007 B
Python
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.
|
|
|
|
Works on model classes and objects.
|
|
"""
|
|
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
|
|
|
|
|
|
def model_app_label(obj):
|
|
"""
|
|
Returns the app label of a model instance or class.
|
|
"""
|
|
return model_options(obj).app_label |