forked from 0x2620/pandora
use postgres json field
This commit is contained in:
parent
bbaaeb7263
commit
1bac062a50
24 changed files with 284 additions and 45 deletions
25
pandora/documentcollection/migrations/0003_jsonfield.py
Normal file
25
pandora/documentcollection/migrations/0003_jsonfield.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.4 on 2018-06-19 17:23
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.contrib.postgres.fields.jsonb
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('documentcollection', '0002_collection_groups'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunSQL(
|
||||
'ALTER TABLE "documentcollection_collection" ALTER COLUMN "query" TYPE jsonb USING "query"::text::jsonb'
|
||||
),
|
||||
migrations.RunSQL(
|
||||
'ALTER TABLE "documentcollection_collection" ALTER COLUMN "sort" TYPE jsonb USING "sort"::text::jsonb'
|
||||
),
|
||||
migrations.RunSQL(
|
||||
'ALTER TABLE "documentcollection_collection" ALTER COLUMN "poster_frames" TYPE jsonb USING "poster_frames"::text::jsonb'
|
||||
),
|
||||
]
|
||||
|
|
@ -11,11 +11,10 @@ from django.db.models import Max
|
|||
from django.contrib.auth.models import User, Group
|
||||
from django.conf import settings
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from oxdjango.fields import JSONField
|
||||
|
||||
import ox
|
||||
|
||||
from oxdjango.fields import DictField, TupleField
|
||||
|
||||
from archive import extract
|
||||
from user.utils import update_groups
|
||||
|
||||
|
|
@ -47,16 +46,16 @@ class Collection(models.Model):
|
|||
name = models.CharField(max_length=255)
|
||||
status = models.CharField(max_length=20, default='private')
|
||||
_status = ['private', 'public', 'featured']
|
||||
query = DictField(default={"static": True})
|
||||
query = JSONField(default=lambda: {"static": True}, editable=False)
|
||||
type = models.CharField(max_length=255, default='static')
|
||||
description = models.TextField(default='')
|
||||
|
||||
icon = models.ImageField(default=None, blank=True, upload_to=get_icon_path)
|
||||
|
||||
view = models.TextField(default=get_collectionview)
|
||||
sort = TupleField(default=get_collectionsort, editable=False)
|
||||
sort = JSONField(default=get_collectionsort, editable=False)
|
||||
|
||||
poster_frames = TupleField(default=[], editable=False)
|
||||
poster_frames = JSONField(default=[], editable=False)
|
||||
|
||||
#is through table still required?
|
||||
documents = models.ManyToManyField('document.Document', related_name='collections',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue