Project

General

Profile

0002-django.contrib.postgres-s-JSONField-is-deprecated-71.patch

Benjamin Dauvergne, 23 November 2022 04:24 PM

Download (13.2 KB)

View differences:

Subject: [PATCH 2/2] django.contrib.postgres's JSONField is deprecated
 (#71619)

 .../apps/journal/migrations/0001_initial.py        |  8 ++++++--
 src/authentic2/apps/journal/models.py              |  7 ++++++-
 .../custom_user/migrations/0020_deleteduser.py     | 10 ++++++----
 .../migrations/0029_profile_profiletype.py         | 10 ++++++----
 src/authentic2/custom_user/models.py               |  6 +++++-
 src/authentic2/migrations/0026_token.py            |  8 ++++++--
 src/authentic2/models.py                           |  8 ++++++--
 .../migrations/0001_initial.py                     |  8 ++++++--
 src/authentic2_auth_oidc/models.py                 |  6 +++++-
 .../migrations/0001_initial.py                     | 14 +++++++++-----
 src/authentic2_auth_saml/models.py                 |  6 +++++-
 11 files changed, 66 insertions(+), 25 deletions(-)
src/authentic2/apps/journal/migrations/0001_initial.py
1 1
# Generated by Django 2.2.15 on 2020-08-23 16:56
2 2

  
3 3
import django.contrib.postgres.fields
4
import django.contrib.postgres.fields.jsonb
5 4
import django.db.models.deletion
6 5
from django.conf import settings
7 6
from django.db import migrations, models
8 7
from django.utils import timezone
9 8

  
9
try:
10
    from django.db.models import JSONField
11
except ImportError:
12
    from django.contrib.postgres.fields.jsonb import JSONField
13

  
10 14

  
11 15
class Migration(migrations.Migration):
12 16

  
......
65 69
                        verbose_name='reference ct ids',
66 70
                    ),
67 71
                ),
68
                ('data', django.contrib.postgres.fields.jsonb.JSONField(null=True, verbose_name='data')),
72
                ('data', JSONField(null=True, verbose_name='data')),
69 73
                (
70 74
                    'session',
71 75
                    models.ForeignKey(
src/authentic2/apps/journal/models.py
26 26
from django.conf import settings
27 27
from django.contrib.auth import get_user_model
28 28
from django.contrib.contenttypes.models import ContentType
29
from django.contrib.postgres.fields import ArrayField, JSONField
29
from django.contrib.postgres.fields import ArrayField
30 30
from django.contrib.postgres.fields.jsonb import KeyTextTransform
31 31
from django.core.exceptions import ObjectDoesNotExist
32 32
from django.db import models
33 33
from django.db.models import Count, F, Q, QuerySet, Value
34

  
35
try:
36
    from django.db.models import JSONField
37
except ImportError:
38
    from django.contrib.postgres.fields import JSONField
34 39
from django.db.models.functions import Trunc
35 40
from django.utils.timezone import now, utc
36 41
from django.utils.translation import gettext_lazy as _
src/authentic2/custom_user/migrations/0020_deleteduser.py
1 1
# Generated by Django 2.2.12 on 2020-05-05 14:16
2 2

  
3
import django.contrib.postgres.fields.jsonb
4 3
from django.db import migrations, models
5 4

  
5
try:
6
    from django.db.models import JSONField
7
except ImportError:
8
    from django.contrib.postgres.fields.jsonb import JSONField
9

  
6 10

  
7 11
class Migration(migrations.Migration):
8 12

  
......
30 34
                ),
31 35
                (
32 36
                    'old_data',
33
                    django.contrib.postgres.fields.jsonb.JSONField(
34
                        blank=True, null=True, verbose_name='Old data'
35
                    ),
37
                    JSONField(blank=True, null=True, verbose_name='Old data'),
36 38
                ),
37 39
            ],
38 40
            options={
src/authentic2/custom_user/migrations/0029_profile_profiletype.py
2 2

  
3 3
import uuid
4 4

  
5
import django.contrib.postgres.fields.jsonb
6 5
import django.db.models.deletion
7 6
from django.conf import settings
8 7
from django.db import migrations, models
9 8

  
9
try:
10
    from django.db.models import JSONField
11
except ImportError:
12
    from django.contrib.postgres.fields.jsonb import JSONField
13

  
10 14

  
11 15
class Migration(migrations.Migration):
12 16

  
......
48 52
                ),
49 53
                (
50 54
                    'data',
51
                    django.contrib.postgres.fields.jsonb.JSONField(
52
                        blank=True, null=True, verbose_name='data'
53
                    ),
55
                    JSONField(blank=True, null=True, verbose_name='data'),
54 56
                ),
55 57
                (
56 58
                    'profile_type',
src/authentic2/custom_user/models.py
27 27
from django.contrib.auth.models import Permission as AuthPermission
28 28
from django.contrib.auth.models import _user_has_module_perms, _user_has_perm
29 29
from django.contrib.contenttypes.fields import GenericRelation
30
from django.contrib.postgres.fields import JSONField
31 30
from django.core.exceptions import MultipleObjectsReturned, ValidationError
32 31
from django.core.mail import send_mail
33 32
from django.db import models, transaction
34 33
from django.db.models import Q
34

  
35
try:
36
    from django.db.models import JSONField
37
except ImportError:
38
    from django.contrib.postgres.fields import JSONField
35 39
from django.urls import reverse
36 40
from django.utils import timezone
37 41
from django.utils.translation import gettext_lazy as _
src/authentic2/migrations/0026_token.py
2 2

  
3 3
import uuid
4 4

  
5
import django.contrib.postgres.fields.jsonb
6 5
from django.db import migrations, models
7 6

  
7
try:
8
    from django.db.models import JSONField
9
except ImportError:
10
    from django.contrib.postgres.fields.jsonb import JSONField
11

  
8 12

  
9 13
class Migration(migrations.Migration):
10 14

  
......
29 33
                ('kind', models.CharField(max_length=32, verbose_name='Kind')),
30 34
                (
31 35
                    'content',
32
                    django.contrib.postgres.fields.jsonb.JSONField(blank=True, verbose_name='Content'),
36
                    JSONField(blank=True, verbose_name='Content'),
33 37
                ),
34 38
                ('created', models.DateTimeField(verbose_name='Creation date', auto_now_add=True)),
35 39
                ('expires', models.DateTimeField(verbose_name='Expires')),
src/authentic2/models.py
27 27
from django.contrib import auth
28 28
from django.contrib.contenttypes.fields import GenericForeignKey
29 29
from django.contrib.contenttypes.models import ContentType
30
from django.contrib.postgres.fields import jsonb
31 30
from django.contrib.postgres.indexes import GinIndex
32 31
from django.contrib.postgres.search import SearchVectorField
33 32
from django.core.exceptions import PermissionDenied, ValidationError
34 33
from django.db import DatabaseError, models, transaction
35 34
from django.db.models.query import Q
35

  
36
try:
37
    from django.db.models import JSONField
38
except ImportError:
39
    from django.contrib.postgres.fields import JSONField
36 40
from django.urls import reverse
37 41
from django.utils import timezone
38 42
from django.utils.http import urlquote
......
538 542
        verbose_name=_('Identifier'), primary_key=True, default=uuid.uuid4, editable=False
539 543
    )
540 544
    kind = models.CharField(verbose_name=_('Kind'), max_length=32)
541
    content = jsonb.JSONField(verbose_name=_('Content'), blank=True)
545
    content = JSONField(verbose_name=_('Content'), blank=True)
542 546
    created = models.DateTimeField(verbose_name=_('Creation date'), auto_now_add=True)
543 547
    expires = models.DateTimeField(verbose_name=_('Expires'))
544 548

  
src/authentic2_auth_oidc/migrations/0001_initial.py
1
import django.contrib.postgres.fields.jsonb
2 1
from django.conf import settings
3 2
from django.db import migrations, models
4 3

  
4
try:
5
    from django.db.models import JSONField
6
except ImportError:
7
    from django.contrib.postgres.fields.jsonb import JSONField
8

  
5 9
import authentic2_auth_oidc.models
6 10

  
7 11

  
......
88 92
                ('scopes', models.CharField(max_length=128, verbose_name='scopes', blank=True)),
89 93
                (
90 94
                    'jwkset_json',
91
                    django.contrib.postgres.fields.jsonb.JSONField(
95
                    JSONField(
92 96
                        blank=True,
93 97
                        null=True,
94 98
                        verbose_name='JSON WebKey set',
src/authentic2_auth_oidc/models.py
17 17
import json
18 18

  
19 19
from django.conf import settings
20
from django.contrib.postgres.fields import JSONField
21 20
from django.core.exceptions import ValidationError
22 21
from django.db import models
22

  
23
try:
24
    from django.db.models import JSONField
25
except ImportError:
26
    from django.contrib.postgres.fields import JSONField
23 27
from django.shortcuts import render
24 28
from django.utils.translation import gettext_lazy as _
25 29
from django.utils.translation import pgettext_lazy
src/authentic2_auth_saml/migrations/0001_initial.py
1 1
# Generated by Django 2.2.26 on 2022-06-15 15:00
2 2

  
3
import django.contrib.postgres.fields.jsonb
4 3
import django.db.models.deletion
5 4
from django.db import migrations, models
6 5

  
6
try:
7
    from django.db.models import JSONField
8
except ImportError:
9
    from django.contrib.postgres.fields.jsonb import JSONField
10

  
7 11
import authentic2_auth_saml.models
8 12
from authentic2_auth_saml.models import NAME_ID_FORMAT_CHOICES
9 13

  
......
203 207
                ),
204 208
                (
205 209
                    'lookup_by_attributes',
206
                    django.contrib.postgres.fields.jsonb.JSONField(
210
                    JSONField(
207 211
                        blank=True,
208 212
                        default=list,
209 213
                        help_text=(
......
218 222
                ),
219 223
                (
220 224
                    'a2_attribute_mapping',
221
                    django.contrib.postgres.fields.jsonb.JSONField(
225
                    JSONField(
222 226
                        blank=True,
223 227
                        default=list,
224 228
                        help_text=(
......
230 234
                ),
231 235
                (
232 236
                    'attribute_mapping',
233
                    django.contrib.postgres.fields.jsonb.JSONField(
237
                    JSONField(
234 238
                        blank=True,
235 239
                        default=dict,
236 240
                        help_text=(
......
242 246
                ),
243 247
                (
244 248
                    'superuser_mapping',
245
                    django.contrib.postgres.fields.jsonb.JSONField(
249
                    JSONField(
246 250
                        blank=True,
247 251
                        default=dict,
248 252
                        editable=False,
src/authentic2_auth_saml/models.py
18 18

  
19 19
import lasso
20 20
from django.conf import settings
21
from django.contrib.postgres.fields import JSONField
22 21
from django.core.exceptions import ValidationError
23 22
from django.db import models
23

  
24
try:
25
    from django.db.models import JSONField
26
except ImportError:
27
    from django.contrib.postgres.fields import JSONField
24 28
from django.urls import reverse
25 29
from django.utils.safestring import mark_safe
26 30
from django.utils.translation import gettext_lazy as _
27
-