class FloorPlanConfig(NautobotAppConfig):
"""App configuration for the nautobot_floor_plan app."""
name = "nautobot_floor_plan"
verbose_name = "Floor Plans"
version = __version__
author = "Network to Code, LLC"
description = "Nautobot App for representing rack positions on per-location floor plan grids."
base_url = "floor-plan"
custom_validators = "utils.custom_validators.custom_validators"
required_settings = []
default_settings = {
"default_x_axis_labels": AxisLabelsChoices.NUMBERS,
"default_y_axis_labels": AxisLabelsChoices.NUMBERS,
"x_size_limit": None,
"y_size_limit": None,
"zoom_duration": 5000,
"highlight_duration": 20000,
"default_statuses": {
"FloorPlanTile": [
{"name": "Active", "color": "4caf50"},
{"name": "Reserved", "color": "00bcd4"},
{"name": "Decommissioning", "color": "ffc107"},
{"name": "Unavailable", "color": "111111"},
{"name": "Planned", "color": "00bcd4"},
],
},
}
docs_view_name = "plugins:nautobot_floor_plan:docs"
searchable_models = ["floorplan"]
def validate_config_options(self):
"""Validates app configuration options."""
x_axis_labels = get_app_settings_or_config("nautobot_floor_plan", "default_x_axis_labels")
y_axis_labels = get_app_settings_or_config("nautobot_floor_plan", "default_y_axis_labels")
valid_choices = AxisLabelsChoices.values()
if x_axis_labels not in valid_choices or y_axis_labels not in valid_choices:
msg = f"nautobot_floor_plan improperly configured. Valid config options for default_x_axis_labels or default_y_axis_labels are: {', '.join(valid_choices)}, plugin config is: default_x_axis_labels: {x_axis_labels}, default_y_axis_labels: {y_axis_labels}"
raise ImproperlyConfigured(msg)
def ready(self):
"""Callback after app is loaded."""
super().ready()
from .placement.defaults import register_builtins # pylint: disable=import-outside-toplevel
from .signals import ( # pylint: disable=import-outside-toplevel
handle_placement_config_change,
post_migrate_apply_placement_config,
post_migrate_create__add_statuses,
)
post_migrate.connect(post_migrate_create__add_statuses, sender=self)
# Register the native placeable types (rack/device/power panel/power feed). Other apps push
# their own registrations from their ready(); floor-plan never imports them.
register_builtins()
# Merge admin-defined FloorPlanObjectType rows over the code/app registrations after migrate
# (safe: tables exist and every app's ready() has run). Runtime edits bump a cache version
# that each worker re-merges lazily via placement.config.refresh_if_stale().
post_migrate.connect(post_migrate_apply_placement_config, sender=self)
object_type_model = self.get_model("FloorPlanObjectType")
post_save.connect(handle_placement_config_change, sender=object_type_model)
post_delete.connect(handle_placement_config_change, sender=object_type_model)
self.validate_config_options()