Skip to content

Commit

Permalink
Remove jsonfield third-party dependencies (GeoNode#7673)
Browse files Browse the repository at this point in the history
Adapt code to django's native `models.JSONField` instead. This native JSONfield has been introduced in Django 3.1, as per https://docs.djangoproject.com/en/3.2/releases/3.1/#jsonfield-for-all-supported-database-backends
  • Loading branch information
ricardogsilva authored Jun 14, 2021
1 parent 9bd121f commit 6e4208b
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 22 deletions.
3 changes: 1 addition & 2 deletions geonode/geoapps/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from django.db import migrations, models
import django.db.models.deletion
import jsonfield.fields


class Migration(migrations.Migration):
Expand Down Expand Up @@ -36,7 +35,7 @@ class Migration(migrations.Migration):
name='GeoAppData',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('blob', jsonfield.fields.JSONField(default={})),
('blob', models.JSONField(default={})),
('resource', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='geoapps.GeoApp')),
],
),
Expand Down
4 changes: 1 addition & 3 deletions geonode/geoapps/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
from django.db.models import signals
from django.utils.translation import ugettext_lazy as _

from jsonfield import JSONField

from guardian.shortcuts import get_anonymous_user

from geonode.base.models import ResourceBase, resourcebase_post_save
Expand Down Expand Up @@ -138,7 +136,7 @@ class Meta(ResourceBase.Meta):

class GeoAppData(models.Model):

blob = JSONField(
blob = models.JSONField(
null=False,
default={})

Expand Down
3 changes: 1 addition & 2 deletions geonode/monitoring/migrations/0001_monitoring_init.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-

from django.db import migrations, models
import jsonfield.fields
import datetime


Expand Down Expand Up @@ -53,7 +52,7 @@ class Migration(migrations.Migration):
('value', models.CharField(max_length=255)),
('value_num', models.DecimalField(default=None, null=True, max_digits=16, decimal_places=4, blank=True)),
('value_raw', models.TextField(default=None, null=True, blank=True)),
('data', jsonfield.fields.JSONField(default={})),
('data', models.JSONField(default={})),
('label', models.ForeignKey(to='monitoring.MetricLabel', on_delete=models.CASCADE)),
],
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-

from django.db import migrations, models
import jsonfield.fields
from django.conf import settings


Expand Down Expand Up @@ -31,7 +30,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(unique=True, max_length=255)),
('description', models.CharField(max_length=255)),
('user_threshold', jsonfield.fields.JSONField(default={}, help_text='Threshold definition')),
('user_threshold', models.JSONField(default={}, help_text='Threshold definition')),
],
),
migrations.AddField(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-

from django.db import migrations, models
import jsonfield.fields


class Migration(migrations.Migration):
Expand Down Expand Up @@ -35,6 +34,6 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='notificationcheck',
name='user_threshold',
field=jsonfield.fields.JSONField(default={}, help_text='Expected min/max values for user configuration'),
field=models.JSONField(default={}, help_text='Expected min/max values for user configuration'),
),
]
9 changes: 5 additions & 4 deletions geonode/monitoring/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
from django.db import models
from django.conf import settings
from django.http import Http404
from jsonfield import JSONField

from django.utils.translation import ugettext_noop as _
from django.urls import reverse
Expand Down Expand Up @@ -929,7 +928,7 @@ class MetricValue(models.Model):
value_raw = models.TextField(null=True, default=None, blank=True)
samples_count = models.PositiveIntegerField(
null=False, default=0, blank=False)
data = JSONField(null=False, default={})
data = models.JSONField(null=False, default={})

class Meta:
unique_together = (
Expand Down Expand Up @@ -1094,8 +1093,10 @@ class NotificationCheck(models.Model):
null=False,
blank=False,
help_text="Description of the alert")
user_threshold = JSONField(default={}, null=False, blank=False,
help_text=_("Expected min/max values for user configuration"))
user_threshold = models.JSONField(
default={}, null=False, blank=False,
help_text=_("Expected min/max values for user configuration")
)
metrics = models.ManyToManyField(
Metric,
through='NotificationMetricDefinition',
Expand Down
2 changes: 1 addition & 1 deletion package/debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Build-Depends: python-all-dev (>= 2.6.6-3), debhelper (>= 7.0.50~)

Package: geonode
Architecture: all
Depends: geoserver-geonode (= 2.14.0), apache2, libapache2-mod-wsgi, gdal-bin, libgeos-dev, gettext, postgresql-contrib, postgis, libpq-dev, zip, unzip, language-pack-en, libjpeg-dev, libpng-dev, libxslt1-dev, zlib1g-dev, libffi-dev, libssl-dev, python-setuptools (= 39.0.1-2), python-django, python-pip, python-celery, python-gdal, python-shapely (= 1.5.17-3), python-pyproj, libproj-dev, python-virtualenv, python-paver, python-elasticsearch (= 2.4.1-1), python-sqlalchemy, python-bs4, python-html5lib, python-webencodings, python-lxml, python-psycopg2, python-arcrest (= 10.3-1), python-dateutil, python-pil, python-httplib2, python-shapely (= 1.5.17-3), python-paver, python-gsconfig (= 1.0.10-1), python-gn-gsimporter (= 1.0.9-2), python-owslib (= 0.16.0-1), python-pycsw (= 2.2.0-1), python-decorator, python-timeout-decorator (= 0.4.0-1), python-six (= 1.10.0-1), python-django-allauth, python-django-bootstrap-form (= 3.4-1), python-django-forms-bootstrap (= 3.1.0-2), python-django-activity-stream (= 0.6.5-2), python-django-autocomplete-light (= 2.3.3-2), python-django-filters, python-django-ipware (= 2.1.0-1), python-django-jsonfield (= 1.0.1-2), python-django-jsonfield-compat (= 0.4.4+geonode-1), python-django-multi-email-field (= 0.5.1-2), python-django-taggit, python-django-treebeard, python-django-mptt, python-django-guardian, python-django-tastypie, python-dj-database-url (= 0.4.2-1), python-pinax-notifications (= 4.1.0+geonode-1), python-backports.functools-lru-cache, python-boto3, python-constantly, python-django-geoexplorer (= 4.0.41-1), python-django-appconf, python-django-storages (= 1.6.5-2), python-django-floppyforms (= 1.7.0-2), python-django-invitations (= 1.9.2-2), python-django-bootstrap3-datetimepicker-2 (= 2.5.0+geonode-1), python-slugify, python-uwsgi (= 2.0.17-2), python-websocket-client (= 0.51.0-1), python-django-geonode-client, python-django-modeltranslation, python-geonode-user-messages (= 0.1.14-1), python-geonode-avatar (= 2.1.8-1), python-pinax-ratings (= 3.0.3), python-geonode-dialogos (= 1.2-1), python-geonode-oauth-toolkit (= 1.1.2rc0-1), python-geonode-announcements (= 1.0.13+geonode-1), python-oauthlib (= 2.1.0-1), python-itypes, python-uritemplate, python-jinja2 (= 2.10-1), python-inflection, python-pygments, python-openid, python-configparser, python-sqlalchemy, python-psutil, python-django-cors-headers, python-requests, python-requests-toolbelt, python-django-downloadview, python-django-extra-views, python-django-polymorphic, python-django-basic-authentication-decorator (= 0.9-2), python-django-haystack, python-coverage, python-ply, python-pep8, python-pyshp, python-antlr, python-dicttoxml, python-datautil, python-enum34, python-geographiclib, python-geopy, python-glob2, python-gunicorn, python-hyperlink, python-simplegeneric, python-scandir, python-pyasn1, python-twisted-bin, python-pyasn1-modules, python-ipython-genutils, python-incremental, python-wcwidth, python-ptyprocess, python-zope.interface, python-serial, python-pathlib2, python-pam, python-traitlets, python-automat, python-service-identity, python-prompt-toolkit, python-pexpect, python-twisted-core, python-pickleshare, python-ipython, python-pycountry, python-lxml, python-jwcrypto, python-jdcal, python-maxminddb, python-parse-type, python-pillow, python-pluggy, python-hamcrest, python-openssl, python-pycodestyle, python-xmljson (= 0.1.9-2), python-user-agents (= 1.1.0-2), python-twisted, python-typing, python-py, python-tqdm, python-traitlets, python-mock, python-mako, python-invoke, python-memcached (= 1.59-2), python-yaml, python-dj-pagination (= 2.3.2-2), python-ua-parser (= 0.8.0-4), python-humanfriendly, ${misc:Depends}, ${python:Depends}
Depends: geoserver-geonode (= 2.14.0), apache2, libapache2-mod-wsgi, gdal-bin, libgeos-dev, gettext, postgresql-contrib, postgis, libpq-dev, zip, unzip, language-pack-en, libjpeg-dev, libpng-dev, libxslt1-dev, zlib1g-dev, libffi-dev, libssl-dev, python-setuptools (= 39.0.1-2), python-django, python-pip, python-celery, python-gdal, python-shapely (= 1.5.17-3), python-pyproj, libproj-dev, python-virtualenv, python-paver, python-elasticsearch (= 2.4.1-1), python-sqlalchemy, python-bs4, python-html5lib, python-webencodings, python-lxml, python-psycopg2, python-arcrest (= 10.3-1), python-dateutil, python-pil, python-httplib2, python-shapely (= 1.5.17-3), python-paver, python-gsconfig (= 1.0.10-1), python-gn-gsimporter (= 1.0.9-2), python-owslib (= 0.16.0-1), python-pycsw (= 2.2.0-1), python-decorator, python-timeout-decorator (= 0.4.0-1), python-six (= 1.10.0-1), python-django-allauth, python-django-bootstrap-form (= 3.4-1), python-django-forms-bootstrap (= 3.1.0-2), python-django-activity-stream (= 0.6.5-2), python-django-autocomplete-light (= 2.3.3-2), python-django-filters, python-django-ipware (= 2.1.0-1), python-django-multi-email-field (= 0.5.1-2), python-django-taggit, python-django-treebeard, python-django-mptt, python-django-guardian, python-django-tastypie, python-dj-database-url (= 0.4.2-1), python-pinax-notifications (= 4.1.0+geonode-1), python-backports.functools-lru-cache, python-boto3, python-constantly, python-django-geoexplorer (= 4.0.41-1), python-django-appconf, python-django-storages (= 1.6.5-2), python-django-floppyforms (= 1.7.0-2), python-django-invitations (= 1.9.2-2), python-django-bootstrap3-datetimepicker-2 (= 2.5.0+geonode-1), python-slugify, python-uwsgi (= 2.0.17-2), python-websocket-client (= 0.51.0-1), python-django-geonode-client, python-django-modeltranslation, python-geonode-user-messages (= 0.1.14-1), python-geonode-avatar (= 2.1.8-1), python-pinax-ratings (= 3.0.3), python-geonode-dialogos (= 1.2-1), python-geonode-oauth-toolkit (= 1.1.2rc0-1), python-geonode-announcements (= 1.0.13+geonode-1), python-oauthlib (= 2.1.0-1), python-itypes, python-uritemplate, python-jinja2 (= 2.10-1), python-inflection, python-pygments, python-openid, python-configparser, python-sqlalchemy, python-psutil, python-django-cors-headers, python-requests, python-requests-toolbelt, python-django-downloadview, python-django-extra-views, python-django-polymorphic, python-django-basic-authentication-decorator (= 0.9-2), python-django-haystack, python-coverage, python-ply, python-pep8, python-pyshp, python-antlr, python-dicttoxml, python-datautil, python-enum34, python-geographiclib, python-geopy, python-glob2, python-gunicorn, python-hyperlink, python-simplegeneric, python-scandir, python-pyasn1, python-twisted-bin, python-pyasn1-modules, python-ipython-genutils, python-incremental, python-wcwidth, python-ptyprocess, python-zope.interface, python-serial, python-pathlib2, python-pam, python-traitlets, python-automat, python-service-identity, python-prompt-toolkit, python-pexpect, python-twisted-core, python-pickleshare, python-ipython, python-pycountry, python-lxml, python-jwcrypto, python-jdcal, python-maxminddb, python-parse-type, python-pillow, python-pluggy, python-hamcrest, python-openssl, python-pycodestyle, python-xmljson (= 0.1.9-2), python-user-agents (= 1.1.0-2), python-twisted, python-typing, python-py, python-tqdm, python-traitlets, python-mock, python-mako, python-invoke, python-memcached (= 1.59-2), python-yaml, python-dj-pagination (= 2.3.2-2), python-ua-parser (= 0.8.0-4), python-humanfriendly, ${misc:Depends}, ${python:Depends}
Recommends: python-gisdata
Description: Allows the creation, sharing, and collaborative use of geospatial data.
At its core, the GeoNode has a stack based on GeoServer, pycsw,
Expand Down
3 changes: 0 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,13 @@ boto3==1.17.92
tqdm==4.61.1
Deprecated==1.2.12
wrapt==1.12.1
jsonfield==3.1.0
jsonschema==3.2.0

# Django Apps
django-allauth==0.44.0
django-appconf==1.0.4
django-filter==2.4.0
django-imagekit==4.0.2
django-jsonfield==1.4.1
django-jsonfield-compat==0.4.4
django-taggit==1.4.0
django-markdownify==0.9.0
django-mptt==0.12.0
Expand Down
3 changes: 0 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,13 @@ install_requires =
tqdm==4.61.1
Deprecated==1.2.12
wrapt==1.12.1
jsonfield==3.1.0
jsonschema==3.2.0

# Django Apps
django-allauth==0.44.0
django-appconf==1.0.4
django-filter==2.4.0
django-imagekit==4.0.2
django-jsonfield==1.4.1
django-jsonfield-compat==0.4.4
django-taggit==1.4.0
django-markdownify==0.9.0
django-mptt==0.12.0
Expand Down

0 comments on commit 6e4208b

Please sign in to comment.