From 291ebaa3f77d99d2a1ae8ef19d5950b52810117b Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Tue, 23 Jun 2020 13:00:51 +0300 Subject: [PATCH] Items must have a uid now (not null). This is due to the previous change. --- .../migrations/0017_auto_20200623_0958.py | 25 +++++++++++++++++++ django_etebase/models.py | 2 +- django_etebase/views.py | 1 - 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 django_etebase/migrations/0017_auto_20200623_0958.py diff --git a/django_etebase/migrations/0017_auto_20200623_0958.py b/django_etebase/migrations/0017_auto_20200623_0958.py new file mode 100644 index 0000000..e244b13 --- /dev/null +++ b/django_etebase/migrations/0017_auto_20200623_0958.py @@ -0,0 +1,25 @@ +# Generated by Django 3.0.3 on 2020-06-23 09:58 + +import django.core.validators +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('django_etebase', '0016_auto_20200623_0820'), + ] + + operations = [ + migrations.AlterField( + model_name='collection', + name='main_item', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='parent', to='django_etebase.CollectionItem'), + ), + migrations.AlterField( + model_name='collectionitem', + name='uid', + field=models.CharField(db_index=True, max_length=43, validators=[django.core.validators.RegexValidator(message='Not a valid UID', regex='^[a-zA-Z0-9]*$')]), + ), + ] diff --git a/django_etebase/models.py b/django_etebase/models.py index 2702389..87b0ed1 100644 --- a/django_etebase/models.py +++ b/django_etebase/models.py @@ -58,7 +58,7 @@ class Collection(models.Model): class CollectionItem(models.Model): - uid = models.CharField(db_index=True, blank=False, null=True, + uid = models.CharField(db_index=True, blank=False, max_length=43, validators=[UidValidator]) collection = models.ForeignKey(Collection, related_name='items', on_delete=models.CASCADE) version = models.PositiveSmallIntegerField() diff --git a/django_etebase/views.py b/django_etebase/views.py index 4f5d757..2e4bf3c 100644 --- a/django_etebase/views.py +++ b/django_etebase/views.py @@ -228,7 +228,6 @@ class CollectionItemViewSet(BaseViewSet): raise Http404("Collection does not exist") # XXX Potentially add this for performance: .prefetch_related('revisions__chunks') queryset = type(self).queryset.filter(collection__pk=collection.pk, - uid__isnull=False, revisions__current=True) return queryset