Skip to content

Commit

Permalink
Merge pull request #1087 from maykinmedia/fix/2193-replace-better-adm…
Browse files Browse the repository at this point in the history
…in-arrayfield

♻️ [#2193] Replace django-better-admin-arrayfield with django-jsonform
  • Loading branch information
stevenbal authored Mar 12, 2024
2 parents 3a27bb2 + 646b1ec commit 3bbd1a3
Show file tree
Hide file tree
Showing 30 changed files with 161 additions and 98 deletions.
2 changes: 1 addition & 1 deletion requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ django-colorfield
django-registration
django-view-breadcrumbs
markdown
django_better_admin_arrayfield
django-jsonform
humanfriendly
git+https://github.com/maykinmedia/[email protected]#egg=mail-editor
fontawesomefree
Expand Down
11 changes: 6 additions & 5 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ django==4.2.10
# django-htmx
# django-import-export
# django-js-asset
# django-jsonform
# django-localflavor
# django-log-outgoing-requests
# django-open-forms-client
Expand Down Expand Up @@ -144,10 +145,6 @@ django-autoslug==1.9.8
# via -r requirements/base.in
django-axes==5.25.0
# via -r requirements/base.in
django-better-admin-arrayfield==1.4.2
# via
# -r requirements/base.in
# mozilla-django-oidc-db
django-choices==2.0.0
# via mail-editor
django-ckeditor==6.7.0
Expand Down Expand Up @@ -201,6 +198,10 @@ django-ipware==4.0.0
# via django-axes
django-js-asset==2.2.0
# via django-ckeditor
django-jsonform==2.22.0
# via
# -r requirements/base.in
# mozilla-django-oidc-db
django-localflavor==3.1
# via -r requirements/base.in
django-log-outgoing-requests==0.6.1
Expand Down Expand Up @@ -374,7 +375,7 @@ messagebird==2.1.0
# via -r requirements/base.in
mozilla-django-oidc==2.0.0
# via mozilla-django-oidc-db
mozilla-django-oidc-db==0.12.0
mozilla-django-oidc-db==0.14.1
# via -r requirements/base.in
notifications-api-common==0.2.2
# via -r requirements/base.in
Expand Down
13 changes: 7 additions & 6 deletions requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ django==4.2.10
# django-htmx
# django-import-export
# django-js-asset
# django-jsonform
# django-localflavor
# django-log-outgoing-requests
# django-open-forms-client
Expand Down Expand Up @@ -231,11 +232,6 @@ django-axes==5.25.0
# via
# -c requirements/base.txt
# -r requirements/base.txt
django-better-admin-arrayfield==1.4.2
# via
# -c requirements/base.txt
# -r requirements/base.txt
# mozilla-django-oidc-db
django-choices==2.0.0
# via
# -c requirements/base.txt
Expand Down Expand Up @@ -329,6 +325,11 @@ django-js-asset==2.2.0
# -c requirements/base.txt
# -r requirements/base.txt
# django-ckeditor
django-jsonform==2.22.0
# via
# -c requirements/base.txt
# -r requirements/base.txt
# mozilla-django-oidc-db
django-localflavor==3.1
# via
# -c requirements/base.txt
Expand Down Expand Up @@ -665,7 +666,7 @@ mozilla-django-oidc==2.0.0
# -c requirements/base.txt
# -r requirements/base.txt
# mozilla-django-oidc-db
mozilla-django-oidc-db==0.12.0
mozilla-django-oidc-db==0.14.1
# via
# -c requirements/base.txt
# -r requirements/base.txt
Expand Down
13 changes: 7 additions & 6 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ django==4.2.10
# django-htmx
# django-import-export
# django-js-asset
# django-jsonform
# django-localflavor
# django-log-outgoing-requests
# django-open-forms-client
Expand Down Expand Up @@ -270,11 +271,6 @@ django-axes==5.25.0
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
django-better-admin-arrayfield==1.4.2
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
# mozilla-django-oidc-db
django-choices==2.0.0
# via
# -c requirements/ci.txt
Expand Down Expand Up @@ -372,6 +368,11 @@ django-js-asset==2.2.0
# -c requirements/ci.txt
# -r requirements/ci.txt
# django-ckeditor
django-jsonform==2.22.0
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
# mozilla-django-oidc-db
django-localflavor==3.1
# via
# -c requirements/ci.txt
Expand Down Expand Up @@ -767,7 +768,7 @@ mozilla-django-oidc==2.0.0
# -c requirements/ci.txt
# -r requirements/ci.txt
# mozilla-django-oidc-db
mozilla-django-oidc-db==0.12.0
mozilla-django-oidc-db==0.14.1
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
Expand Down
3 changes: 1 addition & 2 deletions src/digid_eherkenning_oidc_generics/admin.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from django.contrib import admin
from django.utils.translation import gettext_lazy as _

from django_better_admin_arrayfield.admin.mixins import DynamicArrayMixin
from solo.admin import SingletonModelAdmin

from .forms import OpenIDConnectDigiDConfigForm, OpenIDConnectEHerkenningConfigForm
from .models import OpenIDConnectDigiDConfig, OpenIDConnectEHerkenningConfig


class OpenIDConnectConfigBaseAdmin(DynamicArrayMixin, SingletonModelAdmin):
class OpenIDConnectConfigBaseAdmin(SingletonModelAdmin):
fieldsets = (
(
_("Activation"),
Expand Down
10 changes: 5 additions & 5 deletions src/digid_eherkenning_oidc_generics/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import digid_eherkenning_oidc_generics.models
from django.db import migrations, models
import django_better_admin_arrayfield.models.fields
import django_jsonform.models.fields
import mozilla_django_oidc_db.models


Expand Down Expand Up @@ -127,7 +127,7 @@ class Migration(migrations.Migration):
),
(
"oidc_exempt_urls",
django_better_admin_arrayfield.models.fields.ArrayField(
django_jsonform.models.fields.ArrayField(
base_field=models.CharField(
max_length=1000, verbose_name="Exempt URL"
),
Expand Down Expand Up @@ -188,7 +188,7 @@ class Migration(migrations.Migration):
),
(
"oidc_rp_scopes_list",
django_better_admin_arrayfield.models.fields.ArrayField(
django_jsonform.models.fields.ArrayField(
base_field=models.CharField(
max_length=50, verbose_name="OpenID Connect scope"
),
Expand Down Expand Up @@ -319,7 +319,7 @@ class Migration(migrations.Migration):
),
(
"oidc_exempt_urls",
django_better_admin_arrayfield.models.fields.ArrayField(
django_jsonform.models.fields.ArrayField(
base_field=models.CharField(
max_length=1000, verbose_name="Exempt URL"
),
Expand Down Expand Up @@ -380,7 +380,7 @@ class Migration(migrations.Migration):
),
(
"oidc_rp_scopes_list",
django_better_admin_arrayfield.models.fields.ArrayField(
django_jsonform.models.fields.ArrayField(
base_field=models.CharField(
max_length=50, verbose_name="OpenID Connect scope"
),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Generated by Django 4.2.10 on 2024-03-11 16:12

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


class Migration(migrations.Migration):

dependencies = [
("digid_eherkenning_oidc_generics", "0002_auto_20240109_1055"),
]

operations = [
migrations.AlterField(
model_name="openidconnectdigidconfig",
name="oidc_exempt_urls",
field=django_jsonform.models.fields.ArrayField(
base_field=models.CharField(max_length=1000, verbose_name="Exempt URL"),
blank=True,
default=list,
help_text="This is a list of absolute url paths, regular expressions for url paths, or Django view names. This plus the mozilla-django-oidc urls are exempted from the session renewal by the SessionRefresh middleware.",
size=None,
verbose_name="URLs exempt from session renewal",
),
),
migrations.AlterField(
model_name="openidconnecteherkenningconfig",
name="oidc_exempt_urls",
field=django_jsonform.models.fields.ArrayField(
base_field=models.CharField(max_length=1000, verbose_name="Exempt URL"),
blank=True,
default=list,
help_text="This is a list of absolute url paths, regular expressions for url paths, or Django view names. This plus the mozilla-django-oidc urls are exempted from the session renewal by the SessionRefresh middleware.",
size=None,
verbose_name="URLs exempt from session renewal",
),
),
]
2 changes: 1 addition & 1 deletion src/digid_eherkenning_oidc_generics/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.utils.functional import classproperty
from django.utils.translation import gettext_lazy as _

from django_better_admin_arrayfield.models.fields import ArrayField
from django_jsonform.models.fields import ArrayField
from mozilla_django_oidc_db.models import CachingMixin, OpenIDConnectConfigBase

from .digid_settings import DIGID_CUSTOM_OIDC_DB_PREFIX
Expand Down
2 changes: 1 addition & 1 deletion src/open_inwoner/conf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
"solo",
"colorfield",
"view_breadcrumbs",
"django_better_admin_arrayfield",
"django_jsonform",
"simple_certmanager",
"zgw_consumers",
"notifications_api_common",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Generated by Django 3.2.23 on 2024-01-22 10:18

from django.db import migrations, models
import django_better_admin_arrayfield.models.fields
import django_jsonform.models.fields


class Migration(migrations.Migration):
Expand All @@ -14,7 +14,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name="siteconfiguration",
name="recipients_email_digest",
field=django_better_admin_arrayfield.models.fields.ArrayField(
field=django_jsonform.models.fields.ArrayField(
base_field=models.EmailField(max_length=254),
blank=True,
default=list,
Expand Down
2 changes: 1 addition & 1 deletion src/open_inwoner/configurations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from django.utils.translation import gettext_lazy as _

from colorfield.fields import ColorField
from django_better_admin_arrayfield.models.fields import ArrayField
from django_jsonform.models.fields import ArrayField
from filer.fields.image import FilerImageField
from ordered_model.models import OrderedModel, OrderedModelManager
from solo.models import SingletonModel
Expand Down
4 changes: 4 additions & 0 deletions src/open_inwoner/configurations/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ def setUp(self):
self.form["secondary_font_color"] = "#FFFFFF"
self.form["accent_color"] = "#FFFFFF"
self.form["accent_font_color"] = "#FFFFFF"
# django-jsonform requires JS to work properly and with Webtest the default
# value for ArrayFields is an empty string, causing it crash to when trying to parse
# that value as JSON
self.form["recipients_email_digest"] = "[]"

def test_valid_path_is_saved(self):
config = SiteConfiguration.get_solo()
Expand Down
4 changes: 4 additions & 0 deletions src/open_inwoner/configurations/tests/test_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ def test_contrast_is_checked(self):
form["secondary_font_color"] = "#FFFFFF"
form["accent_color"] = "#FFFFFF"
form["accent_font_color"] = "#FFFFFF"
# django-jsonform requires JS to work properly and with Webtest the default
# value for ArrayFields is an empty string, causing it crash to when trying to parse
# that value as JSON
form["recipients_email_digest"] = "[]"
response = form.submit("_continue").follow()

messages = list(response.context["messages"])
Expand Down
5 changes: 5 additions & 0 deletions src/open_inwoner/configurations/tests/test_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ def setUp(self):
reverse("admin:configurations_siteconfiguration_change"), user=self.user
).forms["siteconfiguration_form"]

# django-jsonform requires JS to work properly and with Webtest the default
# value for ArrayFields is an empty string, causing it crash to when trying to parse
# that value as JSON
self.form["recipients_email_digest"] = "[]"

def test_upload_font_correct_filetype(self):
font_file = Upload("valid.ttf", b"content", content_type="font/ttf")
self.form["name"] = "Test"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Generated by Django 3.2.15 on 2023-01-23 15:19

from django.db import migrations, models
import django_better_admin_arrayfield.models.fields
import django_jsonform.models.fields


class Migration(migrations.Migration):
Expand All @@ -14,7 +14,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name="openzaakconfig",
name="allowed_file_extensions",
field=django_better_admin_arrayfield.models.fields.ArrayField(
field=django_jsonform.models.fields.ArrayField(
base_field=models.CharField(
max_length=8, verbose_name="Allowed file extensions"
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Generated by Django 3.2.15 on 2023-01-25 10:12

from django.db import migrations, models
import django_better_admin_arrayfield.models.fields
import django_jsonform.models.fields
import open_inwoner.openzaak.models


Expand All @@ -15,7 +15,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name="openzaakconfig",
name="allowed_file_extensions",
field=django_better_admin_arrayfield.models.fields.ArrayField(
field=django_jsonform.models.fields.ArrayField(
base_field=models.CharField(
max_length=8, verbose_name="Allowed file extensions"
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import django.db.models.deletion
from django.db import migrations, models

import django_better_admin_arrayfield.models.fields
import django_jsonform.models.fields


class Migration(migrations.Migration):
Expand Down Expand Up @@ -49,7 +49,7 @@ class Migration(migrations.Migration):
),
(
"zaaktype_uuids",
django_better_admin_arrayfield.models.fields.ArrayField(
django_jsonform.models.fields.ArrayField(
base_field=models.UUIDField(verbose_name="Zaaktype UUID"),
default=list,
size=None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from django.db import migrations, models
import django.db.models.deletion
import django_better_admin_arrayfield.models.fields
import django_jsonform.models.fields


class Migration(migrations.Migration):
Expand Down Expand Up @@ -38,7 +38,7 @@ class Migration(migrations.Migration):
),
(
"zaaktype_uuids",
django_better_admin_arrayfield.models.fields.ArrayField(
django_jsonform.models.fields.ArrayField(
base_field=models.UUIDField(verbose_name="Zaaktype UUID"),
default=list,
size=None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from django.db import migrations, models
import django.db.models.deletion
import django_better_admin_arrayfield.models.fields
import django_jsonform.models.fields


class Migration(migrations.Migration):
Expand Down Expand Up @@ -34,7 +34,7 @@ class Migration(migrations.Migration):
),
(
"zaaktype_uuids",
django_better_admin_arrayfield.models.fields.ArrayField(
django_jsonform.models.fields.ArrayField(
base_field=models.UUIDField(verbose_name="Zaaktype UUID"),
default=list,
size=None,
Expand Down
Loading

0 comments on commit 3bbd1a3

Please sign in to comment.