mirror of
https://github.com/ramvignesh-b/pi-ku.git
synced 2026-05-04 08:56:52 +00:00
feat: enable media file handling and allow manual assignment of letter public_id
This commit is contained in:
@@ -168,3 +168,5 @@ USE_TZ = True
|
||||
# https://docs.djangoproject.com/en/6.0/howto/static-files/
|
||||
|
||||
STATIC_URL = "static/"
|
||||
MEDIA_URL = "/media/"
|
||||
MEDIA_ROOT = BASE_DIR / "media"
|
||||
|
||||
@@ -15,6 +15,8 @@ Including another URLconf
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
|
||||
from django.conf import settings
|
||||
from django.conf.urls.static import static
|
||||
from django.contrib import admin
|
||||
from django.urls import include, path
|
||||
|
||||
@@ -23,3 +25,6 @@ urlpatterns = [
|
||||
path("api/auth/", include("users.urls")), # user related operations
|
||||
path("api/letters/", include("letters.urls")), # letter related operations
|
||||
]
|
||||
|
||||
if settings.DEBUG:
|
||||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
|
||||
@@ -16,7 +16,7 @@ class Letter(models.Model):
|
||||
SEALED = "SEALED", "Sealed"
|
||||
BURNED = "BURNED", "Burned"
|
||||
|
||||
public_id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||
public_id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=True)
|
||||
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name="letters")
|
||||
type = models.CharField(max_length=10, choices=Type.choices, default=Type.KEPT)
|
||||
status = models.CharField(max_length=10, choices=Status.choices, default=Status.DRAFT)
|
||||
|
||||
@@ -30,7 +30,7 @@ class LetterSerializer(serializers.ModelSerializer):
|
||||
"updated_at",
|
||||
"images",
|
||||
] # user to be fetched from request
|
||||
read_only_fields = ["public_id", "created_at", "updated_at"]
|
||||
read_only_fields = ["created_at", "updated_at"]
|
||||
|
||||
def validate(self, data):
|
||||
if (data.get("encrypted_content") or data.get("encrypted_metadata")) and not data.get("encrypted_dek"):
|
||||
|
||||
Reference in New Issue
Block a user