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
7 changes: 1 addition & 6 deletions openwisp_network_topology/base/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
import swapper
from django.core.exceptions import ValidationError
from django.db import models
from django.db.models import Q
from django.db.models import JSONField, Q
from django.db.models.signals import post_delete, post_save
from django.dispatch import receiver
from django.utils.timezone import now
from django.utils.translation import gettext_lazy as _
from jsonfield import JSONField
from model_utils import Choices
from model_utils.fields import StatusField
from rest_framework.utils.encoders import JSONEncoder
Expand Down Expand Up @@ -48,16 +47,12 @@ class AbstractLink(ShareableOrgMixin, TimeStampedEditableModel):
properties = JSONField(
default=dict,
blank=True,
load_kwargs={"object_pairs_hook": OrderedDict},
dump_kwargs={"indent": 4, "cls": JSONEncoder},
)
user_properties = JSONField(
verbose_name=_("user defined properties"),
help_text=_("If you need to add additional data to this link use this field"),
default=dict,
blank=True,
load_kwargs={"object_pairs_hook": OrderedDict},
dump_kwargs={"indent": 4, "cls": JSONEncoder},
)
status_changed = models.DateTimeField(auto_now=True)

Expand Down
8 changes: 2 additions & 6 deletions openwisp_network_topology/base/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
import swapper
from django.core.exceptions import ValidationError
from django.db import models
from django.db.models import JSONField
from django.db.models.signals import post_delete, post_save
from django.dispatch import receiver
from django.utils.functional import cached_property
from django.utils.timezone import now
from django.utils.translation import gettext_lazy as _
from jsonfield import JSONField
from rest_framework.utils.encoders import JSONEncoder

from openwisp_users.mixins import ShareableOrgMixin
Expand All @@ -32,20 +32,16 @@ class AbstractNode(ShareableOrgMixin, TimeStampedEditableModel):
)
label = models.CharField(max_length=64, blank=True)
# netjson ID and local_addresses
addresses = JSONField(default=[], blank=True)
addresses = JSONField(default=list, blank=True)
properties = JSONField(
default=dict,
blank=True,
load_kwargs={"object_pairs_hook": OrderedDict},
dump_kwargs={"indent": 4, "cls": JSONEncoder},
)
user_properties = JSONField(
verbose_name=_("user defined properties"),
help_text=_("If you need to add additional data to this node use this field"),
default=dict,
blank=True,
load_kwargs={"object_pairs_hook": OrderedDict},
dump_kwargs={"indent": 4, "cls": JSONEncoder},
)

class Meta:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Generated migration to replace third-party JSONField with Django built-in JSONField
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('topology', '0016_alter_topology_parser'),
]

operations = [
migrations.AlterField(
model_name='link',
name='properties',
field=models.JSONField(blank=True, default=dict),
),
migrations.AlterField(
model_name='link',
name='user_properties',
field=models.JSONField(
blank=True,
default=dict,
help_text='If you need to add additional data to this link use this field',
verbose_name='user defined properties'
),
),
migrations.AlterField(
model_name='node',
name='addresses',
field=models.JSONField(blank=True, default=list),
),
migrations.AlterField(
model_name='node',
name='properties',
field=models.JSONField(blank=True, default=dict),
),
migrations.AlterField(
model_name='node',
name='user_properties',
field=models.JSONField(
blank=True,
default=dict,
help_text='If you need to add additional data to this node use this field',
verbose_name='user defined properties'
),
),
]
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
openwisp-users @ https://github.com/openwisp/openwisp-users/tarball/1.2
netdiff @ https://github.com/openwisp/netdiff/tarball/1.2
jsonfield~=3.1.0
django-flat-json-widget~=0.3.1
openwisp-utils[celery,channels] @ https://github.com/openwisp/openwisp-utils/tarball/1.2
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Generated migration to replace third-party JSONField with Django built-in JSONField
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('sample_network_topology', '0004_default_groups'),
]

operations = [
migrations.AlterField(
model_name='link',
name='properties',
field=models.JSONField(blank=True, default=dict),
),
migrations.AlterField(
model_name='link',
name='user_properties',
field=models.JSONField(
blank=True,
default=dict,
help_text='If you need to add additional data to this link use this field',
verbose_name='user defined properties'
),
),
migrations.AlterField(
model_name='node',
name='addresses',
field=models.JSONField(blank=True, default=list),
),
migrations.AlterField(
model_name='node',
name='properties',
field=models.JSONField(blank=True, default=dict),
),
migrations.AlterField(
model_name='node',
name='user_properties',
field=models.JSONField(
blank=True,
default=dict,
help_text='If you need to add additional data to this node use this field',
verbose_name='user defined properties'
),
),
]
Loading