def display_name(audit_or_model_or_name, instance=None): audit = None if isinstance(audit_or_model_or_name, (Audit, basestring)): if isinstance(audit_or_model_or_name, Audit): audit = audit_or_model_or_name name = audit.model extra_args = [audit.instance] else: name = audit_or_model_or_name extra_args = [] if name.startswith('udf:'): return UserDefinedCollectionValue.get_display_model_name( name, *extra_args) else: name = audit_or_model_or_name.__class__.__name__ if audit: return audit.model_display_name() cls = safe_get_model_class(name) if issubclass(cls, Convertible): # Sometimes instance will be None here, so we'll use the default name return cls.display_name(instance) else: return name
def display_name(model_or_name): if isinstance(model_or_name, basestring): name = model_or_name if name.startswith('udf:'): name = UserDefinedCollectionValue.get_display_model_name(name) else: name = model_or_name.__class__.__name__ if name.lower() == 'plot': return 'Planting Site' else: return name