From cfbda0f0e669162b46a6c077976a3da0202e7b58 Mon Sep 17 00:00:00 2001 From: Laurent Date: Thu, 26 Jun 2025 14:20:42 +0200 Subject: [PATCH] remove junk and make store_id nullable for DataAccess --- .../0008_alter_dataaccess_store_id.py | 18 ++++++++++++++++++ sync/models/data_access.py | 2 +- sync/serializers.py | 6 ------ 3 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 sync/migrations/0008_alter_dataaccess_store_id.py diff --git a/sync/migrations/0008_alter_dataaccess_store_id.py b/sync/migrations/0008_alter_dataaccess_store_id.py new file mode 100644 index 0000000..d89a922 --- /dev/null +++ b/sync/migrations/0008_alter_dataaccess_store_id.py @@ -0,0 +1,18 @@ +# Generated by Django 5.1 on 2025-06-26 12:20 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('sync', '0007_dataaccess_store_id'), + ] + + operations = [ + migrations.AlterField( + model_name='dataaccess', + name='store_id', + field=models.CharField(blank=True, default='', max_length=100, null=True), + ), + ] diff --git a/sync/models/data_access.py b/sync/models/data_access.py index b4019fa..bc2507c 100644 --- a/sync/models/data_access.py +++ b/sync/models/data_access.py @@ -17,7 +17,7 @@ class DataAccess(BaseModel): shared_with = models.ManyToManyField(settings.AUTH_USER_MODEL, related_name='shared_data') model_name = models.CharField(max_length=50) model_id = models.UUIDField() - store_id = models.CharField(max_length=100, default="") # a value matching LeStorage directory sub-stores. Matches the name of the directory. + store_id = models.CharField(max_length=100, default="", blank=True, null=True) # a value matching LeStorage directory sub-stores. Matches the name of the directory. granted_at = models.DateTimeField(auto_now_add=True) def delete_dependencies(self): diff --git a/sync/serializers.py b/sync/serializers.py index f37e6ba..a48fa58 100644 --- a/sync/serializers.py +++ b/sync/serializers.py @@ -6,9 +6,3 @@ class DataAccessSerializer(serializers.ModelSerializer): model = DataAccess fields = '__all__' read_only_fields = ['user'] - - def to_internal_value(self, data): - if 'store_id' in data and data['store_id'] is None: - data = data.copy() # Don't modify the original data - data['store_id'] = "" - return super().to_internal_value(data)