# Path: django_netjsonconfig/settings.py
# BACKENDS = getattr(
#     settings,
#     'NETJSONCONFIG_BACKENDS',
#     (
#         ('netjsonconfig.OpenWrt', 'OpenWRT'),
#         ('netjsonconfig.OpenWisp', 'OpenWISP Firmware 1.x'),
#     ),
# )
# 
# VPN_BACKENDS = getattr(
#     settings,
#     'NETJSONCONFIG_VPN_BACKENDS',
#     (('django_netjsonconfig.vpn_backends.OpenVpn', 'OpenVPN'),),
# )


import json
from copy import deepcopy
from django.http import HttpResponse
from django.utils import timezone
from django.utils.module_loading import import_string
from django.utils.translation import ugettext as _
from django.views.decorators.http import last_modified
from .settings import BACKENDS, VPN_BACKENDS



ALL_BACKENDS = BACKENDS + VPN_BACKENDS

# ``available_schemas`` and ``available_schemas_json``
# will be generated only once at startup
available_schemas = {}
for backend_path, label in ALL_BACKENDS:  # noqa
    backend = import_string(backend_path)
    schema = deepcopy(backend.schema)
    # must use conditional because some custom backends might not specify an hostname
    if 'general' in schema['properties']:
        # hide hostname because it's handled via models
        if 'hostname' in schema['properties']['general']['properties']:
            del schema['properties']['general']['properties']['hostname']
        # remove hosname from required properties
        if 'hostname' in schema['properties']['general'].get('required', []):
            del schema['properties']['general']['required']
    # start editor empty by default, except for VPN schemas

# Path: django_netjsonconfig/settings.py
# BACKENDS = getattr(
#     settings,
#     'NETJSONCONFIG_BACKENDS',
#     (
#         ('netjsonconfig.OpenWrt', 'OpenWRT'),
#         ('netjsonconfig.OpenWisp', 'OpenWISP Firmware 1.x'),
#     ),
# )
# 
# VPN_BACKENDS = getattr(
#     settings,
#     'NETJSONCONFIG_VPN_BACKENDS',
#     (('django_netjsonconfig.vpn_backends.OpenVpn', 'OpenVPN'),),
# )


# Path: django_netjsonconfig/views.py
import json
from copy import deepcopy
from django.http import HttpResponse
from django.utils import timezone
from django.utils.module_loading import import_string
from django.utils.translation import ugettext as _
from django.views.decorators.http import last_modified
from .settings import BACKENDS, VPN_BACKENDS




ALL_BACKENDS = BACKENDS + VPN_BACKENDS

# ``available_schemas`` and ``available_schemas_json``
# will be generated only once at startup
available_schemas = {}
for backend_path, label in ALL_BACKENDS:  # noqa
    backend = import_string(backend_path)
    schema = deepcopy(backend.schema)
    # must use conditional because some custom backends might not specify an hostname
    if 'general' in schema['properties']:
        # hide hostname because it's handled via models
        if 'hostname' in schema['properties']['general']['properties']:
            del schema['properties']['general']['properties']['hostname']
        # remove hosname from required properties
        if 'hostname' in schema['properties']['general'].get('required', []):
            del schema['properties']['general']['required']
    # start editor empty by default, except for VPN schemas

    if (backend_path, label) not in VPN_BACKENDS: