misc: remove some warnings (#75590) #60

Merged
lguerin merged 1 commits from wip/75590-remove-dj32-warnings into main 2023-03-24 08:48:00 +01:00
9 changed files with 20 additions and 24 deletions

View File

@ -15,9 +15,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.apps import apps from django.apps import apps
from django.contrib.postgres.fields import JSONField
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
from django.db import connection from django.db import connection, models
class Command(BaseCommand): class Command(BaseCommand):
@ -26,7 +25,7 @@ class Command(BaseCommand):
def handle(self, **options): def handle(self, **options):
for app in apps.get_models(): for app in apps.get_models():
for field in app._meta.get_fields(): for field in app._meta.get_fields():
if isinstance(field, JSONField): if isinstance(field, models.JSONField):
table_name = app._meta.db_table table_name = app._meta.db_table
column_name = app._meta.get_field(field.name).column column_name = app._meta.get_field(field.name).column
with connection.cursor() as cursor: with connection.cursor() as cursor:

View File

@ -1,4 +1,3 @@
from django.contrib.postgres.fields import JSONField
from django.db import migrations, models from django.db import migrations, models
@ -16,7 +15,7 @@ class Migration(migrations.Migration):
'id', 'id',
models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True), models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True),
), ),
('extra_data', JSONField(null=True)), ('extra_data', models.JSONField(null=True)),
('event', models.ForeignKey(to='agendas.Event', on_delete=models.CASCADE)), ('event', models.ForeignKey(to='agendas.Event', on_delete=models.CASCADE)),
], ],
options={}, options={},

View File

@ -1,7 +1,6 @@
# Generated by Django 1.11.18 on 2020-08-11 14:11 # Generated by Django 1.11.18 on 2020-08-11 14:11
import django.db.models.deletion import django.db.models.deletion
from django.contrib.postgres.fields import JSONField
from django.db import migrations, models from django.db import migrations, models
@ -21,7 +20,7 @@ class Migration(migrations.Migration):
), ),
('timestamp', models.DateTimeField(auto_now_add=True)), ('timestamp', models.DateTimeField(auto_now_add=True)),
('seen', models.BooleanField(default=False)), ('seen', models.BooleanField(default=False)),
('booking_errors', JSONField(default=dict)), ('booking_errors', models.JSONField(default=dict)),
('bookings', models.ManyToManyField(to='agendas.Booking')), ('bookings', models.ManyToManyField(to='agendas.Booking')),
], ],
options={ options={

View File

@ -11,6 +11,6 @@ class Migration(migrations.Migration):
migrations.AddField( migrations.AddField(
model_name='booking', model_name='booking',
name='user_was_present', name='user_was_present',
field=models.NullBooleanField(), field=models.BooleanField(null=True),
), ),
] ]

View File

@ -1,4 +1,3 @@
import django.contrib.postgres.fields.jsonb
from django.db import migrations, models from django.db import migrations, models
@ -12,7 +11,7 @@ class Migration(migrations.Migration):
migrations.AddField( migrations.AddField(
model_name='subscription', model_name='subscription',
name='extra_data', name='extra_data',
field=django.contrib.postgres.fields.jsonb.JSONField(null=True), field=models.JSONField(null=True),
), ),
migrations.AddField( migrations.AddField(
model_name='subscription', model_name='subscription',

View File

@ -1,4 +1,3 @@
import django.contrib.postgres.fields.jsonb
from django.db import migrations, models from django.db import migrations, models
@ -18,7 +17,7 @@ class Migration(migrations.Migration):
), ),
('slug', models.SlugField(max_length=160, unique=True, verbose_name='Identifier')), ('slug', models.SlugField(max_length=160, unique=True, verbose_name='Identifier')),
('label', models.CharField(max_length=150, verbose_name='Label')), ('label', models.CharField(max_length=150, verbose_name='Label')),
('custom_fields', django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=list)), ('custom_fields', models.JSONField(blank=True, default=list)),
], ],
), ),
] ]

View File

@ -1,5 +1,4 @@
import django.contrib.postgres.fields.jsonb from django.db import migrations, models
from django.db import migrations
class Migration(migrations.Migration): class Migration(migrations.Migration):
@ -12,6 +11,6 @@ class Migration(migrations.Migration):
migrations.AddField( migrations.AddField(
model_name='event', model_name='event',
name='custom_fields', name='custom_fields',
field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=dict), field=models.JSONField(blank=True, default=dict),
), ),
] ]

View File

@ -33,7 +33,7 @@ from dateutil.rrule import DAILY, WEEKLY, rrule, rruleset
from django.conf import settings from django.conf import settings
from django.contrib.auth.models import Group from django.contrib.auth.models import Group
from django.contrib.humanize.templatetags.humanize import ordinal from django.contrib.humanize.templatetags.humanize import ordinal
from django.contrib.postgres.fields import ArrayField, JSONField from django.contrib.postgres.fields import ArrayField
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.core.validators import MaxValueValidator, MinValueValidator from django.core.validators import MaxValueValidator, MinValueValidator
from django.db import connection, models, transaction from django.db import connection, models, transaction
@ -1507,7 +1507,7 @@ class Event(models.Model):
meeting_type = models.ForeignKey(MeetingType, null=True, on_delete=models.CASCADE) meeting_type = models.ForeignKey(MeetingType, null=True, on_delete=models.CASCADE)
desk = models.ForeignKey('Desk', null=True, on_delete=models.CASCADE) desk = models.ForeignKey('Desk', null=True, on_delete=models.CASCADE)
resources = models.ManyToManyField('Resource') resources = models.ManyToManyField('Resource')
custom_fields = JSONField(blank=True, default=dict) custom_fields = models.JSONField(blank=True, default=dict)
almost_full_notification_timestamp = models.DateTimeField(null=True, blank=True) almost_full_notification_timestamp = models.DateTimeField(null=True, blank=True)
full_notification_timestamp = models.DateTimeField(null=True, blank=True) full_notification_timestamp = models.DateTimeField(null=True, blank=True)
@ -1706,13 +1706,13 @@ class Event(models.Model):
Value('days'), Value('days'),
'recurrence_days', 'recurrence_days',
function='jsonb_build_object', function='jsonb_build_object',
output_field=JSONField(), output_field=models.JSONField(),
) )
return qs.annotate( return qs.annotate(
overlaps=ArraySubquery( overlaps=ArraySubquery(
overlapping_events.values(json=json_object), overlapping_events.values(json=json_object),
output_field=ArrayField(JSONField()), output_field=ArrayField(models.JSONField()),
) )
) )
@ -2054,7 +2054,7 @@ class Event(models.Model):
class EventsType(models.Model): class EventsType(models.Model):
slug = models.SlugField(_('Identifier'), max_length=160, unique=True) slug = models.SlugField(_('Identifier'), max_length=160, unique=True)
label = models.CharField(_('Label'), max_length=150) label = models.CharField(_('Label'), max_length=150)
custom_fields = JSONField(blank=True, default=list) custom_fields = models.JSONField(blank=True, default=list)
def __str__(self): def __str__(self):
return self.label return self.label
@ -2124,7 +2124,7 @@ class BookingColor(models.Model):
class Booking(models.Model): class Booking(models.Model):
event = models.ForeignKey(Event, on_delete=models.CASCADE) event = models.ForeignKey(Event, on_delete=models.CASCADE)
extra_data = JSONField(null=True) extra_data = models.JSONField(null=True)
anonymization_datetime = models.DateTimeField(null=True) anonymization_datetime = models.DateTimeField(null=True)
cancellation_datetime = models.DateTimeField(null=True) cancellation_datetime = models.DateTimeField(null=True)
email_reminder_datetime = models.DateTimeField(null=True) email_reminder_datetime = models.DateTimeField(null=True)
@ -2145,7 +2145,7 @@ class Booking(models.Model):
user_first_name = models.CharField(max_length=250, blank=True) user_first_name = models.CharField(max_length=250, blank=True)
user_email = models.EmailField(blank=True) user_email = models.EmailField(blank=True)
user_phone_number = models.CharField(max_length=30, blank=True) user_phone_number = models.CharField(max_length=30, blank=True)
user_was_present = models.NullBooleanField() user_was_present = models.BooleanField(null=True)
user_check_type_slug = models.CharField(max_length=160, blank=True, null=True) user_check_type_slug = models.CharField(max_length=160, blank=True, null=True)
user_check_type_label = models.CharField(max_length=150, blank=True, null=True) user_check_type_label = models.CharField(max_length=150, blank=True, null=True)
out_of_min_delay = models.BooleanField(default=False) out_of_min_delay = models.BooleanField(default=False)
@ -3043,7 +3043,7 @@ class EventCancellationReport(models.Model):
timestamp = models.DateTimeField(auto_now_add=True) timestamp = models.DateTimeField(auto_now_add=True)
seen = models.BooleanField(default=False) seen = models.BooleanField(default=False)
bookings = models.ManyToManyField(Booking) bookings = models.ManyToManyField(Booking)
booking_errors = JSONField(default=dict) booking_errors = models.JSONField(default=dict)
def __str__(self): def __str__(self):
return '%s - %s' % (self.timestamp.strftime('%Y-%m-%d %H:%M:%S'), self.event) return '%s - %s' % (self.timestamp.strftime('%Y-%m-%d %H:%M:%S'), self.event)
@ -3287,7 +3287,7 @@ class Subscription(models.Model):
user_first_name = models.CharField(max_length=250) user_first_name = models.CharField(max_length=250)
user_email = models.EmailField(blank=True) user_email = models.EmailField(blank=True)
user_phone_number = models.CharField(max_length=30, blank=True) user_phone_number = models.CharField(max_length=30, blank=True)
extra_data = JSONField(null=True) extra_data = models.JSONField(null=True)
date_start = models.DateField() date_start = models.DateField()
date_end = models.DateField() date_end = models.DateField()

View File

@ -87,6 +87,8 @@ DATABASES = {
} }
} }
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
# Internationalization # Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/ # https://docs.djangoproject.com/en/1.7/topics/i18n/