Collection: add content support.
parent
c56cbb3f82
commit
66e5062461
@ -0,0 +1,19 @@
|
||||
# Generated by Django 3.0.3 on 2020-03-12 14:14
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('django_etesync', '0026_collectionitemrevision_meta'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='collection',
|
||||
name='mainItem',
|
||||
field=models.OneToOneField(null=True, on_delete=django.db.models.deletion.PROTECT, related_name='of_collection', to='django_etesync.CollectionItem'),
|
||||
),
|
||||
]
|
@ -0,0 +1,24 @@
|
||||
# Generated by Django 3.0.3 on 2020-03-12 18:19
|
||||
|
||||
import django.core.validators
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('django_etesync', '0027_collection_mainitem'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='collectionitem',
|
||||
name='encryptionKey',
|
||||
field=models.BinaryField(editable=True, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='collectionitem',
|
||||
name='uid',
|
||||
field=models.CharField(db_index=True, max_length=44, null=True, validators=[django.core.validators.RegexValidator(message='Not a valid UID', regex='[a-zA-Z0-9]')]),
|
||||
),
|
||||
]
|
@ -0,0 +1,31 @@
|
||||
# Generated by Django 3.0.3 on 2020-03-12 18:49
|
||||
|
||||
from django.db import migrations
|
||||
from django_etesync.serializers import generate_rev_uid
|
||||
|
||||
|
||||
def add_collection_main_item(apps, schema_editor):
|
||||
Collection = apps.get_model('django_etesync', 'Collection')
|
||||
CollectionItem = apps.get_model('django_etesync', 'CollectionItem')
|
||||
CollectionItemRevision = apps.get_model('django_etesync', 'CollectionItemRevision')
|
||||
|
||||
for col in Collection.objects.all():
|
||||
main_item = CollectionItem.objects.create(uid=None, encryptionKey=None, version=col.version, collection=col)
|
||||
col.mainItem = main_item
|
||||
col.save()
|
||||
|
||||
CollectionItemRevision.objects.create(
|
||||
uid=generate_rev_uid(),
|
||||
hmac='hmac-hash',
|
||||
item=main_item)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('django_etesync', '0028_auto_20200312_1819'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(add_collection_main_item),
|
||||
]
|
@ -0,0 +1,19 @@
|
||||
# Generated by Django 3.0.3 on 2020-03-12 18:59
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('django_etesync', '0029_auto_20200312_1849'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='collection',
|
||||
name='mainItem',
|
||||
field=models.OneToOneField(on_delete=django.db.models.deletion.PROTECT, related_name='of_collection', to='django_etesync.CollectionItem'),
|
||||
),
|
||||
]
|
Loading…
Reference in New Issue