Chunks: move to reside under the collection.

This commit is contained in:
Tom Hacohen
2020-08-04 15:19:45 +03:00
parent 1d5baece1e
commit 393b85d3ca
6 changed files with 77 additions and 10 deletions

View File

@@ -85,23 +85,22 @@ def chunk_directory_path(instance, filename):
if custom_func is not None:
return custom_func(instance, filename)
item = instance.item
col = item.collection
col = instance.collection
user_id = col.owner.id
return Path('user_{}'.format(user_id), col.uid, item.uid, instance.uid)
return Path('user_{}'.format(user_id), col.uid, instance.uid)
class CollectionItemChunk(models.Model):
uid = models.CharField(db_index=True, blank=False, null=False,
max_length=60, validators=[UidValidator])
item = models.ForeignKey(CollectionItem, related_name='chunks', on_delete=models.CASCADE)
collection = models.ForeignKey(Collection, related_name='chunks', on_delete=models.CASCADE)
chunkFile = models.FileField(upload_to=chunk_directory_path, max_length=150, unique=True)
def __str__(self):
return self.uid
class Meta:
unique_together = ('item', 'uid')
unique_together = ('collection', 'uid')
def generate_stoken_uid():