From e062fcd4298e6f0b995f6759cc1a32d6504691e1 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 4 Jun 2020 15:23:10 +0300 Subject: [PATCH] Revision: add salt. --- .../0015_collectionitemrevision_salt.py | 18 ++++++++++++++++++ django_etesync/models.py | 1 + django_etesync/serializers.py | 3 ++- 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 django_etesync/migrations/0015_collectionitemrevision_salt.py diff --git a/django_etesync/migrations/0015_collectionitemrevision_salt.py b/django_etesync/migrations/0015_collectionitemrevision_salt.py new file mode 100644 index 0000000..f5553c9 --- /dev/null +++ b/django_etesync/migrations/0015_collectionitemrevision_salt.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.3 on 2020-06-04 12:18 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('django_etesync', '0014_auto_20200602_1558'), + ] + + operations = [ + migrations.AddField( + model_name='collectionitemrevision', + name='salt', + field=models.BinaryField(default=b'', editable=True), + ), + ] diff --git a/django_etesync/models.py b/django_etesync/models.py index 18c14a9..53239e7 100644 --- a/django_etesync/models.py +++ b/django_etesync/models.py @@ -115,6 +115,7 @@ class CollectionItemRevision(models.Model): stoken = models.OneToOneField(Stoken, on_delete=models.PROTECT) uid = models.CharField(db_index=True, unique=True, blank=False, null=False, max_length=43, validators=[Base64Url256BitlValidator]) + salt = models.BinaryField(editable=True, blank=False, null=False, default=b'') item = models.ForeignKey(CollectionItem, related_name='revisions', on_delete=models.CASCADE) meta = models.BinaryField(editable=True, blank=False, null=False) current = models.BooleanField(db_index=True, default=True, null=True) diff --git a/django_etesync/serializers.py b/django_etesync/serializers.py index 178c914..1f5d3c2 100644 --- a/django_etesync/serializers.py +++ b/django_etesync/serializers.py @@ -106,11 +106,12 @@ class CollectionItemRevisionSerializer(serializers.ModelSerializer): queryset=models.RevisionChunkRelation.objects.all(), many=True ) + salt = BinaryBase64Field() meta = BinaryBase64Field() class Meta: model = models.CollectionItemRevision - fields = ('chunks', 'meta', 'uid', 'deleted') + fields = ('chunks', 'meta', 'uid', 'salt', 'deleted') class CollectionItemSerializer(serializers.ModelSerializer):