Project

General

Profile

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

Benjamin Dauvergne, 24 November 2022 02:47 PM

Download (14.3 KB)

View differences:

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

 .../apps/journal/migrations/0001_initial.py       |  9 +++++++--
 src/authentic2/apps/journal/models.py             |  7 ++++++-
 .../custom_user/migrations/0020_deleteduser.py    | 11 +++++++----
 .../migrations/0029_profile_profiletype.py        | 11 +++++++----
 src/authentic2/custom_user/models.py              |  7 ++++++-
 src/authentic2/migrations/0026_token.py           |  9 +++++++--
 src/authentic2/models.py                          |  8 ++++++--
 .../migrations/0001_initial.py                    |  9 +++++++--
 src/authentic2_auth_oidc/models.py                |  7 ++++++-
 .../migrations/0001_initial.py                    | 15 ++++++++++-----
 src/authentic2_auth_saml/models.py                |  7 ++++++-
 11 files changed, 75 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
import django
3 4
import django.contrib.postgres.fields
4
import django.contrib.postgres.fields.jsonb
5 5
import django.db.models.deletion
6 6
from django.conf import settings
7 7
from django.db import migrations, models
8 8
from django.utils import timezone
9 9

  
10
if django.VERSION < (3, 1):
11
    from django.contrib.postgres.fields.jsonb import JSONField  # noqa pylint: disable=ungrouped-imports
12
else:
13
    from django.db.models import JSONField
14

  
10 15

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

  
......
65 70
                        verbose_name='reference ct ids',
66 71
                    ),
67 72
                ),
68
                ('data', django.contrib.postgres.fields.jsonb.JSONField(null=True, verbose_name='data')),
73
                ('data', JSONField(null=True, verbose_name='data')),
69 74
                (
70 75
                    'session',
71 76
                    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
......
39 39

  
40 40
from . import sql
41 41

  
42
if django.VERSION < (3, 1):
43
    from django.contrib.postgres.fields.jsonb import JSONField  # noqa pylint: disable=ungrouped-imports
44
else:
45
    from django.db.models import JSONField
46

  
42 47
logger = logging.getLogger(__name__)
43 48

  
44 49
User = get_user_model()
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
3
import django
4 4
from django.db import migrations, models
5 5

  
6
if django.VERSION < (3, 1):
7
    from django.contrib.postgres.fields.jsonb import JSONField  # noqa pylint: disable=ungrouped-imports
8
else:
9
    from django.db.models import JSONField
10

  
6 11

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

  
......
30 35
                ),
31 36
                (
32 37
                    'old_data',
33
                    django.contrib.postgres.fields.jsonb.JSONField(
34
                        blank=True, null=True, verbose_name='Old data'
35
                    ),
38
                    JSONField(blank=True, null=True, verbose_name='Old data'),
36 39
                ),
37 40
            ],
38 41
            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
5
import django
6 6
import django.db.models.deletion
7 7
from django.conf import settings
8 8
from django.db import migrations, models
9 9

  
10
if django.VERSION < (3, 1):
11
    from django.contrib.postgres.fields.jsonb import JSONField  # noqa pylint: disable=ungrouped-imports
12
else:
13
    from django.db.models import JSONField
14

  
10 15

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

  
......
48 53
                ),
49 54
                (
50 55
                    'data',
51
                    django.contrib.postgres.fields.jsonb.JSONField(
52
                        blank=True, null=True, verbose_name='data'
53
                    ),
56
                    JSONField(blank=True, null=True, verbose_name='data'),
54 57
                ),
55 58
                (
56 59
                    'profile_type',
src/authentic2/custom_user/models.py
22 22
import os
23 23
import uuid
24 24

  
25
import django
25 26
from django.contrib import auth
26 27
from django.contrib.auth.models import AbstractBaseUser, Group
27 28
from django.contrib.auth.models import Permission as AuthPermission
28 29
from django.contrib.auth.models import _user_has_module_perms, _user_has_perm
29 30
from django.contrib.contenttypes.fields import GenericRelation
30
from django.contrib.postgres.fields import JSONField
31 31
from django.core.exceptions import MultipleObjectsReturned, ValidationError
32 32
from django.core.mail import send_mail
33 33
from django.db import models, transaction
......
57 57
from .backends import DjangoRBACBackend
58 58
from .managers import UserManager, UserQuerySet
59 59

  
60
if django.VERSION < (3, 1):
61
    from django.contrib.postgres.fields.jsonb import JSONField  # noqa pylint: disable=ungrouped-imports
62
else:
63
    from django.db.models import JSONField
64

  
60 65

  
61 66
@RequestCache
62 67
def get_attributes_map():
src/authentic2/migrations/0026_token.py
2 2

  
3 3
import uuid
4 4

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

  
8
if django.VERSION < (3, 1):
9
    from django.contrib.postgres.fields.jsonb import JSONField  # noqa pylint: disable=ungrouped-imports
10
else:
11
    from django.db.models import JSONField
12

  
8 13

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

  
......
29 34
                ('kind', models.CharField(max_length=32, verbose_name='Kind')),
30 35
                (
31 36
                    'content',
32
                    django.contrib.postgres.fields.jsonb.JSONField(blank=True, verbose_name='Content'),
37
                    JSONField(blank=True, verbose_name='Content'),
33 38
                ),
34 39
                ('created', models.DateTimeField(verbose_name='Creation date', auto_now_add=True)),
35 40
                ('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
......
50 49
from . import natural_key as unused_natural_key  # pylint: disable=unused-import
51 50
from .utils.misc import ServiceAccessDenied
52 51

  
52
if django.VERSION < (3, 1):
53
    from django.contrib.postgres.fields.jsonb import JSONField  # noqa pylint: disable=ungrouped-imports
54
else:
55
    from django.db.models import JSONField
56

  
53 57

  
54 58
class UserExternalId(models.Model):
55 59
    user = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name=_('user'), on_delete=models.CASCADE)
......
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
1
import django
2 2
from django.conf import settings
3 3
from django.db import migrations, models
4 4

  
5 5
import authentic2_auth_oidc.models
6 6

  
7
if django.VERSION < (3, 1):
8
    from django.contrib.postgres.fields.jsonb import JSONField  # noqa pylint: disable=ungrouped-imports
9
else:
10
    from django.db.models import JSONField
11

  
7 12

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

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

  
17 17
import json
18 18

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

  
37 37
from . import managers
38 38

  
39
if django.VERSION < (3, 1):
40
    from django.contrib.postgres.fields.jsonb import JSONField  # noqa pylint: disable=ungrouped-imports
41
else:
42
    from django.db.models import JSONField
43

  
39 44

  
40 45
def validate_jwkset(data):
41 46
    data = json.dumps(data)
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
3
import django
4 4
import django.db.models.deletion
5 5
from django.db import migrations, models
6 6

  
7 7
import authentic2_auth_saml.models
8 8
from authentic2_auth_saml.models import NAME_ID_FORMAT_CHOICES
9 9

  
10
if django.VERSION < (3, 1):
11
    from django.contrib.postgres.fields.jsonb import JSONField  # noqa pylint: disable=ungrouped-imports
12
else:
13
    from django.db.models import JSONField
14

  
10 15

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

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

  
17 17
import xml.etree.ElementTree as ET
18 18

  
19
import django
19 20
import lasso
20 21
from django.conf import settings
21
from django.contrib.postgres.fields import JSONField
22 22
from django.core.exceptions import ValidationError
23 23
from django.db import models
24 24
from django.urls import reverse
......
32 32
)
33 33
from authentic2.utils.misc import redirect_to_login
34 34

  
35
if django.VERSION < (3, 1):
36
    from django.contrib.postgres.fields.jsonb import JSONField  # noqa pylint: disable=ungrouped-imports
37
else:
38
    from django.db.models import JSONField
39

  
35 40
NAME_ID_FORMAT_CHOICES = (
36 41
    ('', _('None')),
37 42
    (
38
-