Projet

Général

Profil

0001-misc-remove-postgres.E003-warnings-52028.patch

Nicolas Roche, 16 avril 2021 16:49

Télécharger (19,8 ko)

Voir les différences:

Subject: [PATCH] misc: remove postgres.E003 warnings (#52028)

 .../apps/cartads_cs/migrations/0002_cartadsdatacache.py   | 4 ++--
 .../migrations/0004_cartadsdossier_cartads_steps_cache.py | 2 +-
 .../migrations/0011_cartadsdossier_cartads_cache_infos.py | 2 +-
 passerelle/apps/cartads_cs/models.py                      | 8 ++++----
 .../apps/choosit/migrations/0010_auto_20210202_1304.py    | 3 ++-
 .../apps/mobyt/migrations/0009_auto_20210202_1304.py      | 3 ++-
 .../apps/orange/migrations/0009_auto_20210202_1304.py     | 3 ++-
 passerelle/apps/ovh/migrations/0013_auto_20210202_1304.py | 3 ++-
 .../apps/oxyd/migrations/0009_auto_20210202_1304.py       | 3 ++-
 passerelle/apps/phonecalls/migrations/0001_initial.py     | 2 +-
 passerelle/apps/phonecalls/models.py                      | 2 +-
 .../apps/twilio/migrations/0002_auto_20210202_1304.py     | 3 ++-
 passerelle/base/models.py                                 | 6 +++---
 passerelle/sms/models.py                                  | 6 +++++-
 14 files changed, 30 insertions(+), 20 deletions(-)
passerelle/apps/cartads_cs/migrations/0002_cartadsdatacache.py
16 16
        migrations.CreateModel(
17 17
            name='CartaDSDataCache',
18 18
            fields=[
19 19
                (
20 20
                    'id',
21 21
                    models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
22 22
                ),
23 23
                ('data_type', models.CharField(max_length=50)),
24
                ('data_parameters', django.contrib.postgres.fields.jsonb.JSONField(default={})),
25
                ('data_values', django.contrib.postgres.fields.jsonb.JSONField(default={})),
24
                ('data_parameters', django.contrib.postgres.fields.jsonb.JSONField(default=dict)),
25
                ('data_values', django.contrib.postgres.fields.jsonb.JSONField(default=dict)),
26 26
                ('last_update_datetime', models.DateTimeField(auto_now=True)),
27 27
            ],
28 28
        ),
29 29
    ]
passerelle/apps/cartads_cs/migrations/0004_cartadsdossier_cartads_steps_cache.py
11 11
    dependencies = [
12 12
        ('cartads_cs', '0003_cartadsdossier_name_id'),
13 13
    ]
14 14

  
15 15
    operations = [
16 16
        migrations.AddField(
17 17
            model_name='cartadsdossier',
18 18
            name='cartads_steps_cache',
19
            field=django.contrib.postgres.fields.jsonb.JSONField(default={}),
19
            field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
20 20
        ),
21 21
    ]
passerelle/apps/cartads_cs/migrations/0011_cartadsdossier_cartads_cache_infos.py
11 11
    dependencies = [
12 12
        ('cartads_cs', '0010_cartadsdossier_cartads_cache_code_acces'),
13 13
    ]
14 14

  
15 15
    operations = [
16 16
        migrations.AddField(
17 17
            model_name='cartadsdossier',
18 18
            name='cartads_cache_infos',
19
            field=django.contrib.postgres.fields.jsonb.JSONField(default={}),
19
            field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
20 20
        ),
21 21
    ]
passerelle/apps/cartads_cs/models.py
57 57

  
58 58

  
59 59
def key_value_of_stringstring(d):
60 60
    return {'KeyValueOfstringstring': [{'Key': x, 'Value': y} for x, y in d.items()]}
61 61

  
62 62

  
63 63
class CartaDSDataCache(models.Model):
64 64
    data_type = models.CharField(max_length=50)
65
    data_parameters = JSONField(default={})
66
    data_values = JSONField(default={})
65
    data_parameters = JSONField(default=dict)
66
    data_values = JSONField(default=dict)
67 67
    last_update_datetime = models.DateTimeField(auto_now=True)
68 68

  
69 69

  
70 70
class CartaDSFile(models.Model):
71 71
    tracking_code = models.CharField(max_length=20)
72 72
    id_piece = models.CharField(max_length=20)
73 73
    uploaded_file = models.FileField(upload_to=cartads_file_location)
74 74
    sent_to_cartads = models.DateTimeField(null=True)
......
92 92
    zip_ready = models.BooleanField(default=False)
93 93
    zip_sent = models.BooleanField(default=False)
94 94
    zip_ack_response = models.CharField(null=True, max_length=20)
95 95
    notification_url = models.URLField(null=True)
96 96
    notification_message = models.TextField(null=True)
97 97
    cartads_id_dossier = models.CharField(max_length=50, null=True)
98 98
    cartads_numero_dossier = models.CharField(max_length=50, null=True)
99 99
    cartads_cache_code_acces = models.CharField(max_length=200, null=True)
100
    cartads_cache_infos = JSONField(default={})
101
    cartads_steps_cache = JSONField(default={})
100
    cartads_cache_infos = JSONField(default=dict)
101
    cartads_steps_cache = JSONField(default=dict)
102 102
    last_update_datetime = models.DateTimeField(auto_now=True)
103 103
    subscribers = models.ManyToManyField(CartaDSSubscriber, blank=True)
104 104
    formdata_url = models.CharField(null=True, max_length=200)
105 105

  
106 106

  
107 107
class AbstractCartaDSCS(BaseResource):
108 108

  
109 109
    wsdl_base_url = models.URLField(
passerelle/apps/choosit/migrations/0010_auto_20210202_1304.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.18 on 2021-02-02 12:04
3 3
from __future__ import unicode_literals
4 4

  
5 5
import django.contrib.postgres.fields
6 6
from django.db import migrations, models
7
import passerelle.sms.models
7 8

  
8 9

  
9 10
class Migration(migrations.Migration):
10 11

  
11 12
    dependencies = [
12 13
        ('choosit', '0009_choositsmsgateway_max_message_length'),
13 14
    ]
14 15

  
......
31 32
                        ('fr-metro', 'France mainland (+33 [67])'),
32 33
                        ('fr-domtom', 'France DOM/TOM (+262, etc.)'),
33 34
                        ('be', 'Belgian (+32 4[5-9]) '),
34 35
                        ('all', 'All'),
35 36
                    ],
36 37
                    max_length=32,
37 38
                    null=True,
38 39
                ),
39
                default=['all'],
40
                default=passerelle.sms.models.authorized_default,
40 41
                size=None,
41 42
                verbose_name='Authorized Countries',
42 43
            ),
43 44
        ),
44 45
    ]
passerelle/apps/mobyt/migrations/0009_auto_20210202_1304.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.18 on 2021-02-02 12:04
3 3
from __future__ import unicode_literals
4 4

  
5 5
import django.contrib.postgres.fields
6 6
from django.db import migrations, models
7
import passerelle.sms.models
7 8

  
8 9

  
9 10
class Migration(migrations.Migration):
10 11

  
11 12
    dependencies = [
12 13
        ('mobyt', '0008_auto_20200310_1539'),
13 14
    ]
14 15

  
......
31 32
                        ('fr-metro', 'France mainland (+33 [67])'),
32 33
                        ('fr-domtom', 'France DOM/TOM (+262, etc.)'),
33 34
                        ('be', 'Belgian (+32 4[5-9]) '),
34 35
                        ('all', 'All'),
35 36
                    ],
36 37
                    max_length=32,
37 38
                    null=True,
38 39
                ),
39
                default=['all'],
40
                default=passerelle.sms.models.authorized_default,
40 41
                size=None,
41 42
                verbose_name='Authorized Countries',
42 43
            ),
43 44
        ),
44 45
    ]
passerelle/apps/orange/migrations/0009_auto_20210202_1304.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.18 on 2021-02-02 12:04
3 3
from __future__ import unicode_literals
4 4

  
5 5
import django.contrib.postgres.fields
6 6
from django.db import migrations, models
7
import passerelle.sms.models
7 8

  
8 9

  
9 10
class Migration(migrations.Migration):
10 11

  
11 12
    dependencies = [
12 13
        ('orange', '0008_auto_20200412_1240'),
13 14
    ]
14 15

  
......
31 32
                        ('fr-metro', 'France mainland (+33 [67])'),
32 33
                        ('fr-domtom', 'France DOM/TOM (+262, etc.)'),
33 34
                        ('be', 'Belgian (+32 4[5-9]) '),
34 35
                        ('all', 'All'),
35 36
                    ],
36 37
                    max_length=32,
37 38
                    null=True,
38 39
                ),
39
                default=['all'],
40
                default=passerelle.sms.models.authorized_default,
40 41
                size=None,
41 42
                verbose_name='Authorized Countries',
42 43
            ),
43 44
        ),
44 45
    ]
passerelle/apps/ovh/migrations/0013_auto_20210202_1304.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.18 on 2021-02-02 12:04
3 3
from __future__ import unicode_literals
4 4

  
5 5
import django.contrib.postgres.fields
6 6
from django.db import migrations, models
7
import passerelle.sms.models
7 8

  
8 9

  
9 10
class Migration(migrations.Migration):
10 11

  
11 12
    dependencies = [
12 13
        ('ovh', '0012_auto_20201027_1121'),
13 14
    ]
14 15

  
......
31 32
                        ('fr-metro', 'France mainland (+33 [67])'),
32 33
                        ('fr-domtom', 'France DOM/TOM (+262, etc.)'),
33 34
                        ('be', 'Belgian (+32 4[5-9]) '),
34 35
                        ('all', 'All'),
35 36
                    ],
36 37
                    max_length=32,
37 38
                    null=True,
38 39
                ),
39
                default=['all'],
40
                default=passerelle.sms.models.authorized_default,
40 41
                size=None,
41 42
                verbose_name='Authorized Countries',
42 43
            ),
43 44
        ),
44 45
        migrations.AlterField(
45 46
            model_name='ovhsmsgateway',
46 47
            name='alert_emails',
47 48
            field=django.contrib.postgres.fields.ArrayField(
passerelle/apps/oxyd/migrations/0009_auto_20210202_1304.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.18 on 2021-02-02 12:04
3 3
from __future__ import unicode_literals
4 4

  
5 5
import django.contrib.postgres.fields
6 6
from django.db import migrations, models
7
import passerelle.sms.models
7 8

  
8 9

  
9 10
class Migration(migrations.Migration):
10 11

  
11 12
    dependencies = [
12 13
        ('oxyd', '0008_oxydsmsgateway_max_message_length'),
13 14
    ]
14 15

  
......
31 32
                        ('fr-metro', 'France mainland (+33 [67])'),
32 33
                        ('fr-domtom', 'France DOM/TOM (+262, etc.)'),
33 34
                        ('be', 'Belgian (+32 4[5-9]) '),
34 35
                        ('all', 'All'),
35 36
                    ],
36 37
                    max_length=32,
37 38
                    null=True,
38 39
                ),
39
                default=['all'],
40
                default=passerelle.sms.models.authorized_default,
40 41
                size=None,
41 42
                verbose_name='Authorized Countries',
42 43
            ),
43 44
        ),
44 45
    ]
passerelle/apps/phonecalls/migrations/0001_initial.py
22 22
                (
23 23
                    'id',
24 24
                    models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
25 25
                ),
26 26
                ('callee', models.CharField(max_length=64)),
27 27
                ('caller', models.CharField(max_length=64)),
28 28
                ('start_timestamp', models.DateTimeField(auto_now_add=True)),
29 29
                ('end_timestamp', models.DateTimeField(default=None, null=True)),
30
                ('details', django.contrib.postgres.fields.jsonb.JSONField(default={})),
30
                ('details', django.contrib.postgres.fields.jsonb.JSONField(default=dict)),
31 31
            ],
32 32
            options={
33 33
                'ordering': ['-start_timestamp'],
34 34
                'verbose_name': 'Phone Call',
35 35
            },
36 36
        ),
37 37
        migrations.CreateModel(
38 38
            name='PhoneCalls',
passerelle/apps/phonecalls/models.py
145 145

  
146 146

  
147 147
class Call(models.Model):
148 148
    resource = models.ForeignKey(PhoneCalls, on_delete=models.CASCADE)
149 149
    callee = models.CharField(blank=False, max_length=64)
150 150
    caller = models.CharField(blank=False, max_length=64)
151 151
    start_timestamp = models.DateTimeField(auto_now_add=True)
152 152
    end_timestamp = models.DateTimeField(null=True, default=None)
153
    details = JSONField(default={})
153
    details = JSONField(default=dict)
154 154

  
155 155
    class Meta:
156 156
        verbose_name = _('Phone Call')
157 157
        ordering = ['-start_timestamp']
158 158

  
159 159
    def json(self):
160 160
        # We use make_naive to send localtime, because this API will be used
161 161
        # by javascript, which will not be comfortable with UTC datetimes
passerelle/apps/twilio/migrations/0002_auto_20210202_1304.py
1 1
# -*- coding: utf-8 -*-
2 2
# Generated by Django 1.11.18 on 2021-02-02 12:04
3 3
from __future__ import unicode_literals
4 4

  
5 5
import django.contrib.postgres.fields
6 6
from django.db import migrations, models
7
import passerelle.sms.models
7 8

  
8 9

  
9 10
class Migration(migrations.Migration):
10 11

  
11 12
    dependencies = [
12 13
        ('twilio', '0001_initial'),
13 14
    ]
14 15

  
......
31 32
                        ('fr-metro', 'France mainland (+33 [67])'),
32 33
                        ('fr-domtom', 'France DOM/TOM (+262, etc.)'),
33 34
                        ('be', 'Belgian (+32 4[5-9]) '),
34 35
                        ('all', 'All'),
35 36
                    ],
36 37
                    max_length=32,
37 38
                    null=True,
38 39
                ),
39
                default=['all'],
40
                default=passerelle.sms.models.authorized_default,
40 41
                size=None,
41 42
                verbose_name='Authorized Countries',
42 43
            ),
43 44
        ),
44 45
    ]
passerelle/base/models.py
755 755

  
756 756

  
757 757
class Job(models.Model):
758 758
    resource_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
759 759
    resource_pk = models.PositiveIntegerField()
760 760
    resource = fields.GenericForeignKey('resource_type', 'resource_pk')
761 761
    method_name = models.CharField(max_length=50)
762 762
    natural_id = models.CharField(max_length=256, blank=True, null=True)
763
    parameters = JSONField(default={})
763
    parameters = JSONField(default=dict)
764 764
    creation_timestamp = models.DateTimeField(auto_now_add=True)
765 765
    update_timestamp = models.DateTimeField(auto_now=True)
766 766
    done_timestamp = models.DateTimeField(null=True)
767 767
    after_timestamp = models.DateTimeField(null=True)
768 768
    status = models.CharField(
769 769
        max_length=20,
770 770
        default='registered',
771 771
        choices=(
772 772
            ('registered', _('Registered')),
773 773
            ('running', _('Running')),
774 774
            ('failed', _('Failed')),
775 775
            ('restarted', _('Failed and restarted')),
776 776
            ('completed', _('Completed')),
777 777
        ),
778 778
    )
779
    status_details = JSONField(default={})
779
    status_details = JSONField(default=dict)
780 780

  
781 781
    class Meta:
782 782
        ordering = ('id',)
783 783

  
784 784
    def set_after_timestamp(self, value):
785 785
        if isinstance(value, datetime.datetime):
786 786
            self.after_timestamp = value
787 787
        elif isinstance(value, six.integer_types + (float,)):
......
836 836
@six.python_2_unicode_compatible
837 837
class ResourceLog(models.Model):
838 838
    timestamp = models.DateTimeField(auto_now_add=True)
839 839
    appname = models.CharField(max_length=128, verbose_name='appname', null=True)
840 840
    slug = models.CharField(max_length=128, verbose_name='slug', null=True)
841 841
    levelno = models.IntegerField(verbose_name='log level')
842 842
    sourceip = models.GenericIPAddressField(blank=True, null=True, verbose_name=_('Source IP'))
843 843
    message = models.TextField(verbose_name='message')
844
    extra = JSONField(verbose_name='extras', default={})
844
    extra = JSONField(verbose_name='extras', default=dict)
845 845
    transaction_id = models.UUIDField(null=True, db_index=True)
846 846

  
847 847
    class Meta:
848 848
        ordering = ('id',)
849 849
        permissions = (('see_resourcelog', 'Can see resource logs'),)
850 850

  
851 851
    @property
852 852
    def level(self):
passerelle/sms/models.py
46 46
            'description': 'Destination numbers',
47 47
            "type": "array",
48 48
            "items": {'type': 'string', 'pattern': r'^\+?[-.\s/\d]+$'},
49 49
        },
50 50
    },
51 51
}
52 52

  
53 53

  
54
def authorized_default():
55
    return [SMSResource.ALL]
56

  
57

  
54 58
class SMSResource(BaseResource):
55 59
    manager_form_base_class = SMSConnectorForm
56 60
    category = _('SMS Providers')
57 61
    documentation_url = (
58 62
        'https://doc-publik.entrouvert.com/admin-fonctionnel/les-tutos/configuration-envoi-sms/'
59 63
    )
60 64

  
61 65
    _can_send_messages_description = _('Sending messages is limited to the following API users:')
......
78 82
        (FR_METRO, _('France mainland (+33 [67])')),
79 83
        (FR_DOMTOM, _('France DOM/TOM (+262, etc.)')),
80 84
        (BE_, _('Belgian (+32 4[5-9]) ')),
81 85
        (ALL, _('All')),
82 86
    ]
83 87
    authorized = ArrayField(
84 88
        models.CharField(max_length=32, null=True, choices=AUTHORIZED),
85 89
        verbose_name=_('Authorized Countries'),
86
        default=[ALL],
90
        default=authorized_default,
87 91
    )
88 92

  
89 93
    allow_premium_rate = models.BooleanField(
90 94
        _('Allow premium rate numbers'),
91 95
        default=False,
92 96
        help_text=_('This option is only applyed to France mainland'),
93 97
    )
94 98

  
95
-