dev: separate endpoints for workspace assets and user assets (#420)
This commit is contained in:
parent
b6ee197b40
commit
88754e6fc0
4 changed files with 75 additions and 9 deletions
|
|
@ -1,3 +1,6 @@
|
|||
# Python imports
|
||||
from uuid import uuid4
|
||||
|
||||
# Django import
|
||||
from django.db import models
|
||||
from django.core.exceptions import ValidationError
|
||||
|
|
@ -7,7 +10,9 @@ from . import BaseModel
|
|||
|
||||
|
||||
def get_upload_path(instance, filename):
|
||||
return f"{instance.workspace.id}/{filename}"
|
||||
if instance.workspace_id is not None:
|
||||
return f"{instance.workspace.id}/{uuid4().hex}-{filename}"
|
||||
return f"user-profile/{uuid4().hex}-{filename}"
|
||||
|
||||
|
||||
def file_size(value):
|
||||
|
|
@ -15,6 +20,7 @@ def file_size(value):
|
|||
if value.size > limit:
|
||||
raise ValidationError("File too large. Size should not exceed 5 MB.")
|
||||
|
||||
|
||||
class FileAsset(BaseModel):
|
||||
"""
|
||||
A file asset.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue