Commit f5858327 authored by Florent Chehab's avatar Florent Chehab

JSON field better handling

parent b0079b94
# Generated by Django 2.0.3 on 2018-08-29 19:01
import django.contrib.postgres.fields.jsonb
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('backend', '0024_auto_20180829_1840'),
]
operations = [
migrations.AlterField(
model_name='pendingmoderation',
name='new_object',
field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
),
migrations.AlterField(
model_name='previousdeparturefeedback',
name='courses_and_courses_feedback',
field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
),
migrations.AlterField(
model_name='userdata',
name='config',
field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
),
migrations.AlterField(
model_name='userdata',
name='contact_info',
field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
),
migrations.AlterField(
model_name='userdata',
name='other_data',
field=django.contrib.postgres.fields.jsonb.JSONField(default=dict),
),
]
......@@ -7,7 +7,7 @@ from django.contrib.postgres.fields import JSONField
class BasicModule(MyModelVersionned):
comment = models.TextField(blank=True)
usefull_links = UsefullLinksField(blank=True)
usefull_links = UsefullLinksField(blank=True, default=list)
custom_content = JSONField(blank=True, default=dict)
class Meta:
......
......@@ -14,7 +14,7 @@ class PendingModeration(models.Model):
updated_by = models.ForeignKey(User, on_delete=models.CASCADE)
updated_on = models.DateTimeField(null=True)
new_object = JSONField(default={})
new_object = JSONField(default=dict)
class Meta:
unique_together = ('content_type', 'object_id')
......
......@@ -31,5 +31,5 @@ class UsefullLinksField(JSONField):
def __init__(self, *args, **kwargs):
kwargs['validators'] = [validate_usefull_links]
kwargs['default'] = []
kwargs['default'] = list
super(UsefullLinksField, self).__init__(*args, **kwargs)
......@@ -10,7 +10,7 @@ class PreviousDepartureFeedback(UserRestrictedModule):
departure = models.OneToOneField(
PreviousDeparture, on_delete=models.CASCADE)
courses_and_courses_feedback = JSONField(null=True)
courses_and_courses_feedback = JSONField(default=dict)
adequation_comment = models.TextField()
integration_comment = models.TextField()
adequation_grate = models.PositiveIntegerField(
......
......@@ -9,12 +9,12 @@ from backend.models.tools import NoDelete, IsOwner
class UserData(MyModel):
owner = models.OneToOneField(User, on_delete=models.CASCADE)
contact_info = JSONField(null=True, default={})
contact_info = JSONField(default=dict)
contact_info_is_public = models.BooleanField(default=False)
config = JSONField(null=True, default={})
config = JSONField(default=dict)
black_list = models.ManyToManyField(
University, related_name='+', blank=True)
other_data = JSONField(null=True, default={})
other_data = JSONField(default=dict)
class UserDataSerializer(MyModelSerializer):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment