Projet

Général

Profil

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

Nicolas Roche, 16 avril 2021 10:03

Télécharger (17,4 ko)

Voir les différences:

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

 .../migrations/0013_auto_20210416_0938.py     | 34 +++++++++++++++++++
 passerelle/apps/cartads_cs/models.py          |  8 ++---
 .../migrations/0010_auto_20210416_0936.py     | 34 +++++++++++++++++++
 .../migrations/0010_auto_20210416_0936.py     | 34 +++++++++++++++++++
 .../ovh/migrations/0014_auto_20210416_0936.py | 34 +++++++++++++++++++
 .../migrations/0010_auto_20210416_0937.py     | 34 +++++++++++++++++++
 .../migrations/0004_auto_20210416_0938.py     | 26 ++++++++++++++
 passerelle/apps/phonecalls/models.py          |  2 +-
 .../migrations/0003_auto_20210416_0935.py     | 34 +++++++++++++++++++
 passerelle/base/models.py                     |  6 ++--
 passerelle/sms/models.py                      |  7 +++-
 11 files changed, 244 insertions(+), 9 deletions(-)
 create mode 100644 passerelle/apps/cartads_cs/migrations/0013_auto_20210416_0938.py
 create mode 100644 passerelle/apps/mobyt/migrations/0010_auto_20210416_0936.py
 create mode 100644 passerelle/apps/orange/migrations/0010_auto_20210416_0936.py
 create mode 100644 passerelle/apps/ovh/migrations/0014_auto_20210416_0936.py
 create mode 100644 passerelle/apps/oxyd/migrations/0010_auto_20210416_0937.py
 create mode 100644 passerelle/apps/phonecalls/migrations/0004_auto_20210416_0938.py
 create mode 100644 passerelle/apps/twilio/migrations/0003_auto_20210416_0935.py
passerelle/apps/cartads_cs/migrations/0013_auto_20210416_0938.py
1
# Generated by Django 2.2.19 on 2021-04-16 07:38
2

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

  
6

  
7
class Migration(migrations.Migration):
8

  
9
    dependencies = [
10
        ('cartads_cs', '0012_text_to_jsonb'),
11
    ]
12

  
13
    operations = [
14
        migrations.AlterField(
15
            model_name='cartadsdatacache',
16
            name='data_parameters',
17
            field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
18
        ),
19
        migrations.AlterField(
20
            model_name='cartadsdatacache',
21
            name='data_values',
22
            field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
23
        ),
24
        migrations.AlterField(
25
            model_name='cartadsdossier',
26
            name='cartads_cache_infos',
27
            field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
28
        ),
29
        migrations.AlterField(
30
            model_name='cartadsdossier',
31
            name='cartads_steps_cache',
32
            field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
33
        ),
34
    ]
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/mobyt/migrations/0010_auto_20210416_0936.py
1
# Generated by Django 2.2.19 on 2021-04-16 07:36
2

  
3
import django.contrib.postgres.fields
4
from django.db import migrations, models
5
import passerelle.sms.models
6

  
7

  
8
class Migration(migrations.Migration):
9

  
10
    dependencies = [
11
        ('mobyt', '0009_auto_20210202_1304'),
12
    ]
13

  
14
    operations = [
15
        migrations.AlterField(
16
            model_name='mobytsmsgateway',
17
            name='authorized',
18
            field=django.contrib.postgres.fields.ArrayField(
19
                base_field=models.CharField(
20
                    choices=[
21
                        ('fr-metro', 'France mainland (+33 [67])'),
22
                        ('fr-domtom', 'France DOM/TOM (+262, etc.)'),
23
                        ('be', 'Belgian (+32 4[5-9]) '),
24
                        ('all', 'All'),
25
                    ],
26
                    max_length=32,
27
                    null=True,
28
                ),
29
                default=passerelle.sms.models.authorized_default,
30
                size=None,
31
                verbose_name='Authorized Countries',
32
            ),
33
        ),
34
    ]
passerelle/apps/orange/migrations/0010_auto_20210416_0936.py
1
# Generated by Django 2.2.19 on 2021-04-16 07:36
2

  
3
import django.contrib.postgres.fields
4
from django.db import migrations, models
5
import passerelle.sms.models
6

  
7

  
8
class Migration(migrations.Migration):
9

  
10
    dependencies = [
11
        ('orange', '0009_auto_20210202_1304'),
12
    ]
13

  
14
    operations = [
15
        migrations.AlterField(
16
            model_name='orangesmsgateway',
17
            name='authorized',
18
            field=django.contrib.postgres.fields.ArrayField(
19
                base_field=models.CharField(
20
                    choices=[
21
                        ('fr-metro', 'France mainland (+33 [67])'),
22
                        ('fr-domtom', 'France DOM/TOM (+262, etc.)'),
23
                        ('be', 'Belgian (+32 4[5-9]) '),
24
                        ('all', 'All'),
25
                    ],
26
                    max_length=32,
27
                    null=True,
28
                ),
29
                default=passerelle.sms.models.authorized_default,
30
                size=None,
31
                verbose_name='Authorized Countries',
32
            ),
33
        ),
34
    ]
passerelle/apps/ovh/migrations/0014_auto_20210416_0936.py
1
# Generated by Django 2.2.19 on 2021-04-16 07:36
2

  
3
import django.contrib.postgres.fields
4
from django.db import migrations, models
5
import passerelle.sms.models
6

  
7

  
8
class Migration(migrations.Migration):
9

  
10
    dependencies = [
11
        ('ovh', '0013_auto_20210202_1304'),
12
    ]
13

  
14
    operations = [
15
        migrations.AlterField(
16
            model_name='ovhsmsgateway',
17
            name='authorized',
18
            field=django.contrib.postgres.fields.ArrayField(
19
                base_field=models.CharField(
20
                    choices=[
21
                        ('fr-metro', 'France mainland (+33 [67])'),
22
                        ('fr-domtom', 'France DOM/TOM (+262, etc.)'),
23
                        ('be', 'Belgian (+32 4[5-9]) '),
24
                        ('all', 'All'),
25
                    ],
26
                    max_length=32,
27
                    null=True,
28
                ),
29
                default=passerelle.sms.models.authorized_default,
30
                size=None,
31
                verbose_name='Authorized Countries',
32
            ),
33
        ),
34
    ]
passerelle/apps/oxyd/migrations/0010_auto_20210416_0937.py
1
# Generated by Django 2.2.19 on 2021-04-16 07:37
2

  
3
import django.contrib.postgres.fields
4
from django.db import migrations, models
5
import passerelle.sms.models
6

  
7

  
8
class Migration(migrations.Migration):
9

  
10
    dependencies = [
11
        ('oxyd', '0009_auto_20210202_1304'),
12
    ]
13

  
14
    operations = [
15
        migrations.AlterField(
16
            model_name='oxydsmsgateway',
17
            name='authorized',
18
            field=django.contrib.postgres.fields.ArrayField(
19
                base_field=models.CharField(
20
                    choices=[
21
                        ('fr-metro', 'France mainland (+33 [67])'),
22
                        ('fr-domtom', 'France DOM/TOM (+262, etc.)'),
23
                        ('be', 'Belgian (+32 4[5-9]) '),
24
                        ('all', 'All'),
25
                    ],
26
                    max_length=32,
27
                    null=True,
28
                ),
29
                default=passerelle.sms.models.authorized_default,
30
                size=None,
31
                verbose_name='Authorized Countries',
32
            ),
33
        ),
34
    ]
passerelle/apps/phonecalls/migrations/0004_auto_20210416_0938.py
1
# Generated by Django 2.2.19 on 2021-04-16 07:38
2

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

  
6

  
7
class Migration(migrations.Migration):
8

  
9
    dependencies = [
10
        ('phonecalls', '0003_phonecalls_redirect_url'),
11
    ]
12

  
13
    operations = [
14
        migrations.AlterField(
15
            model_name='call',
16
            name='details',
17
            field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
18
        ),
19
        migrations.AlterField(
20
            model_name='phonecalls',
21
            name='redirect_url',
22
            field=models.URLField(
23
                null=True, verbose_name='URL to redirect to or open when using redirect or newtab parameters'
24
            ),
25
        ),
26
    ]
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/0003_auto_20210416_0935.py
1
# Generated by Django 2.2.19 on 2021-04-16 07:35
2

  
3
import django.contrib.postgres.fields
4
from django.db import migrations, models
5
import passerelle.sms.models
6

  
7

  
8
class Migration(migrations.Migration):
9

  
10
    dependencies = [
11
        ('twilio', '0002_auto_20210202_1304'),
12
    ]
13

  
14
    operations = [
15
        migrations.AlterField(
16
            model_name='twiliosmsgateway',
17
            name='authorized',
18
            field=django.contrib.postgres.fields.ArrayField(
19
                base_field=models.CharField(
20
                    choices=[
21
                        ('fr-metro', 'France mainland (+33 [67])'),
22
                        ('fr-domtom', 'France DOM/TOM (+262, etc.)'),
23
                        ('be', 'Belgian (+32 4[5-9]) '),
24
                        ('all', 'All'),
25
                    ],
26
                    max_length=32,
27
                    null=True,
28
                ),
29
                default=passerelle.sms.models.authorized_default,
30
                size=None,
31
                verbose_name='Authorized Countries',
32
            ),
33
        ),
34
    ]
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:')
......
75 79
    BE_ = 'be'
76 80
    ALL = 'all'
77 81
    AUTHORIZED = [
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
    ]
87

  
83 88
    authorized = ArrayField(
84 89
        models.CharField(max_length=32, null=True, choices=AUTHORIZED),
85 90
        verbose_name=_('Authorized Countries'),
86
        default=[ALL],
91
        default=authorized_default,
87 92
    )
88 93

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

  
95
-