|
@@ -2,8 +2,6 @@ from django.db.models import ManyToOneRel
|
|
|
from django.utils import timezone
|
|
from django.utils import timezone
|
|
|
from django.utils.timezone import localtime
|
|
from django.utils.timezone import localtime
|
|
|
|
|
|
|
|
-from .string import title
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
def dynamic_import(name):
|
|
def dynamic_import(name):
|
|
|
"""
|
|
"""
|
|
@@ -16,29 +14,6 @@ def dynamic_import(name):
|
|
|
return mod
|
|
return mod
|
|
|
|
|
|
|
|
|
|
|
|
|
-def object_type_name(object_type, include_app=True):
|
|
|
|
|
- """
|
|
|
|
|
- Return a human-friendly ObjectType name (e.g. "DCIM > Site").
|
|
|
|
|
- """
|
|
|
|
|
- try:
|
|
|
|
|
- meta = object_type.model_class()._meta
|
|
|
|
|
- app_label = title(meta.app_config.verbose_name)
|
|
|
|
|
- model_name = title(meta.verbose_name)
|
|
|
|
|
- if include_app:
|
|
|
|
|
- return f'{app_label} > {model_name}'
|
|
|
|
|
- return model_name
|
|
|
|
|
- except AttributeError:
|
|
|
|
|
- # Model does not exist
|
|
|
|
|
- return f'{object_type.app_label} > {object_type.model}'
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-def object_type_identifier(object_type):
|
|
|
|
|
- """
|
|
|
|
|
- Return a "raw" ObjectType identifier string suitable for bulk import/export (e.g. "dcim.site").
|
|
|
|
|
- """
|
|
|
|
|
- return f'{object_type.app_label}.{object_type.model}'
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
def local_now():
|
|
def local_now():
|
|
|
"""
|
|
"""
|
|
|
Return the current date & time in the system timezone.
|
|
Return the current date & time in the system timezone.
|