Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions openwisp_controller/config/base/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import collections
import hashlib
import json
import logging
Expand All @@ -7,10 +6,10 @@
from cache_memoize import cache_memoize
from django.core.exceptions import ValidationError
from django.db import models
from django.db.models import JSONField
from django.utils.functional import cached_property
from django.utils.module_loading import import_string
from django.utils.translation import gettext_lazy as _
from jsonfield import JSONField
from netjsonconfig.exceptions import ValidationError as SchemaError

from openwisp_utils.base import TimeStampedEditableModel
Expand Down Expand Up @@ -126,8 +125,6 @@ class BaseConfig(BaseModel):
_("configuration"),
default=dict,
help_text=_("configuration in NetJSON DeviceConfiguration format"),
load_kwargs={"object_pairs_hook": collections.OrderedDict},
dump_kwargs={"indent": 4},
)

__template__ = False
Expand Down
4 changes: 1 addition & 3 deletions openwisp_controller/config/base/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from django.core.exceptions import ObjectDoesNotExist, PermissionDenied, ValidationError
from django.db import models, transaction
from django.db.models import JSONField
from django.utils.translation import gettext_lazy as _
from jsonfield import JSONField
from model_utils import Choices
from model_utils.fields import StatusField
from netjsonconfig import OpenWrt
Expand Down Expand Up @@ -97,8 +97,6 @@ class AbstractConfig(ChecksumCacheMixin, BaseConfig):
'en/stable/general/basics.html#context" target="_blank">'
"context (configuration variables)</a> in JSON format"
),
load_kwargs={"object_pairs_hook": collections.OrderedDict},
dump_kwargs={"indent": 4},
)

_CHECKSUM_CACHE_TIMEOUT = 60 * 60 * 24 * 30 # 10 days
Expand Down
7 changes: 1 addition & 6 deletions openwisp_controller/config/base/device_group.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import collections
from copy import deepcopy

import jsonschema
from django.core.exceptions import ValidationError
from django.db import models
from django.db.models import JSONField
from django.utils.translation import gettext_lazy as _
from jsonfield import JSONField
from jsonschema.exceptions import ValidationError as SchemaError
from swapper import get_model_name, load_model

Expand Down Expand Up @@ -39,8 +38,6 @@ class AbstractDeviceGroup(OrgMixin, TimeStampedEditableModel):
meta_data = JSONField(
blank=True,
default=dict,
load_kwargs={"object_pairs_hook": collections.OrderedDict},
dump_kwargs={"indent": 4},
help_text=_(
"Group meta data, use this field to store data which is related"
" to this group and can be retrieved via the REST API."
Expand All @@ -50,8 +47,6 @@ class AbstractDeviceGroup(OrgMixin, TimeStampedEditableModel):
context = JSONField(
blank=True,
default=dict,
load_kwargs={"object_pairs_hook": collections.OrderedDict},
dump_kwargs={"indent": 4},
help_text=_(
"This field can be used to add meta data for the group"
' or to add "Configuration Variables" to the devices.'
Expand Down
5 changes: 1 addition & 4 deletions openwisp_controller/config/base/multitenancy.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import collections
from copy import deepcopy

import swapper
from django.db import models
from django.db.models import JSONField
from django.utils.translation import gettext_lazy as _
from jsonfield import JSONField

from openwisp_utils.base import KeyField, UUIDModel

Expand Down Expand Up @@ -34,8 +33,6 @@ class AbstractOrganizationConfigSettings(UUIDModel):
context = JSONField(
blank=True,
default=dict,
load_kwargs={"object_pairs_hook": collections.OrderedDict},
dump_kwargs={"indent": 4},
help_text=_(
'This field can be used to add "Configuration Variables"' " to the devices."
),
Expand Down
4 changes: 1 addition & 3 deletions openwisp_controller/config/base/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from django.core.exceptions import ObjectDoesNotExist, ValidationError
from django.db import models, transaction
from django.db.models import JSONField
from django.utils.translation import gettext_lazy as _
from jsonfield import JSONField
from netjsonconfig.exceptions import ValidationError as NetjsonconfigValidationError
from swapper import get_model_name
from taggit.managers import TaggableManager
Expand Down Expand Up @@ -95,8 +95,6 @@ class AbstractTemplate(ShareableOrgMixinUniqueName, BaseConfig):
"template; these default variables will "
"be used during schema validation."
),
load_kwargs={"object_pairs_hook": OrderedDict},
dump_kwargs={"indent": 4},
)
__template__ = True

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Generated migration to replace third-party jsonfield with Django built-in JSONField

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
('config', '0060_cleanup_api_task_notification_types'),
]

operations = [
# Replace jsonfield.fields.JSONField with django.db.models.JSONField
migrations.AlterField(
model_name='config',
name='context',
field=models.JSONField(
blank=True,
default=dict,
help_text=(
'Additional <a href="http://netjsonconfig.openwisp.org/'
'en/stable/general/basics.html#context" target="_blank">'
"context (configuration variables)</a> in JSON format"
),
),
),
migrations.AlterField(
model_name='template',
name='config',
field=models.JSONField(
verbose_name='configuration',
default=dict,
help_text='configuration in NetJSON DeviceConfiguration format',
),
),
migrations.AlterField(
model_name='template',
name='default_values',
field=models.JSONField(
verbose_name='Default Values',
default=dict,
blank=True,
help_text=(
"A dictionary containing the default "
"values for the variables used by this "
"template; these default variables will "
"be used during schema validation."
),
),
),
migrations.AlterField(
model_name='devicegroup',
name='meta_data',
field=models.JSONField(
blank=True,
default=dict,
help_text=(
"Group meta data, use this field to store data which is related"
" to this group and can be retrieved via the REST API."
),
verbose_name='Metadata',
),
),
migrations.AlterField(
model_name='devicegroup',
name='context',
field=models.JSONField(
blank=True,
default=dict,
help_text=(
"This field can be used to add meta data for the group"
' or to add "Configuration Variables" to the devices.'
),
verbose_name='Configuration Variables',
),
),
migrations.AlterField(
model_name='organizationconfigsettings',
name='context',
field=models.JSONField(
blank=True,
default=dict,
help_text=(
'This field can be used to add "Configuration Variables"'
" to the devices."
),
verbose_name='Configuration Variables',
),
),
]
9 changes: 1 addition & 8 deletions openwisp_controller/connection/base/models.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import collections
import logging

import django
import jsonschema
from django.core.exceptions import ValidationError
from django.db import models, transaction
from django.db.models import JSONField
from django.utils import timezone
from django.utils.functional import cached_property
from django.utils.module_loading import import_string
from django.utils.translation import gettext
from django.utils.translation import gettext_lazy as _
from jsonfield import JSONField
from jsonschema.exceptions import ValidationError as SchemaError
from swapper import get_model_name, load_model

Expand Down Expand Up @@ -101,8 +100,6 @@ class AbstractCredentials(ConnectorMixin, ShareableOrgMixinUniqueName, BaseModel
_("parameters"),
default=dict,
help_text=_("global connection parameters"),
load_kwargs={"object_pairs_hook": collections.OrderedDict},
dump_kwargs={"indent": 4},
)
auto_add = models.BooleanField(
_("auto add"),
Expand Down Expand Up @@ -245,8 +242,6 @@ class AbstractDeviceConnection(ConnectorMixin, TimeStampedEditableModel):
"local connection parameters (will override "
"the global parameters if specified)"
),
load_kwargs={"object_pairs_hook": collections.OrderedDict},
dump_kwargs={"indent": 4},
)
# usability improvements
is_working = models.BooleanField(null=True, blank=True, default=None)
Expand Down Expand Up @@ -425,8 +420,6 @@ class AbstractCommand(TimeStampedEditableModel):
input = JSONField(
blank=True,
null=True,
load_kwargs={"object_pairs_hook": collections.OrderedDict},
dump_kwargs={"indent": 4},
)
output = models.TextField(blank=True)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Generated migration to replace third-party jsonfield with Django built-in JSONField

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
('connection', '0009_alter_deviceconnection_unique_together'),
]

operations = [
# Replace jsonfield.fields.JSONField with django.db.models.JSONField
migrations.AlterField(
model_name='credentials',
name='params',
field=models.JSONField(
verbose_name='parameters',
default=dict,
help_text='global connection parameters',
),
),
migrations.AlterField(
model_name='deviceconnection',
name='params',
field=models.JSONField(
verbose_name='parameters',
default=dict,
blank=True,
help_text=(
"local connection parameters (will override "
"the global parameters if specified)"
),
),
),
migrations.AlterField(
model_name='command',
name='input',
field=models.JSONField(
blank=True,
null=True,
),
),
]
Loading