remove junk and make store_id nullable for DataAccess

sync3
Laurent 5 months ago
parent a32b2c2abc
commit cfbda0f0e6
  1. 18
      sync/migrations/0008_alter_dataaccess_store_id.py
  2. 2
      sync/models/data_access.py
  3. 6
      sync/serializers.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),
),
]

@ -17,7 +17,7 @@ class DataAccess(BaseModel):
shared_with = models.ManyToManyField(settings.AUTH_USER_MODEL, related_name='shared_data') shared_with = models.ManyToManyField(settings.AUTH_USER_MODEL, related_name='shared_data')
model_name = models.CharField(max_length=50) model_name = models.CharField(max_length=50)
model_id = models.UUIDField() 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) granted_at = models.DateTimeField(auto_now_add=True)
def delete_dependencies(self): def delete_dependencies(self):

@ -6,9 +6,3 @@ class DataAccessSerializer(serializers.ModelSerializer):
model = DataAccess model = DataAccess
fields = '__all__' fields = '__all__'
read_only_fields = ['user'] 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)

Loading…
Cancel
Save