Fix ebook upload: new books appear at top, 50 MB limit frontend/backend
- Create EBookProgress on upload so new books get a last_read timestamp and sort to the top of the book list - Update frontend file size check from 10 MB to 50 MB - Fix backend error message to say 50 MB instead of 10 MB Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
4274f49971
commit
9c0a046c57
2 changed files with 4 additions and 3 deletions
|
|
@ -67,7 +67,7 @@ def upload_book(request):
|
||||||
return JsonResponse({'error': 'invalid base64 in data_ct'}, status=400)
|
return JsonResponse({'error': 'invalid base64 in data_ct'}, status=400)
|
||||||
|
|
||||||
if raw_size > max_bytes:
|
if raw_size > max_bytes:
|
||||||
return JsonResponse({'error': 'file too large (max 10 MB)'}, status=400)
|
return JsonResponse({'error': 'file too large (max 50 MB)'}, status=400)
|
||||||
|
|
||||||
book = EBook.objects.create(
|
book = EBook.objects.create(
|
||||||
user=request.user,
|
user=request.user,
|
||||||
|
|
@ -76,6 +76,7 @@ def upload_book(request):
|
||||||
data_ct=data_ct,
|
data_ct=data_ct,
|
||||||
data_iv=data_iv,
|
data_iv=data_iv,
|
||||||
)
|
)
|
||||||
|
EBookProgress.objects.create(user=request.user, book=book)
|
||||||
return JsonResponse({'ok': True, 'id': book.id})
|
return JsonResponse({'ok': True, 'id': book.id})
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2884,8 +2884,8 @@ async function uploadEbook(file) {
|
||||||
if (statusEl) statusEl.textContent = 'Only .epub and .pdf files are supported.';
|
if (statusEl) statusEl.textContent = 'Only .epub and .pdf files are supported.';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (file.size > 10 * 1024 * 1024) {
|
if (file.size > 50 * 1024 * 1024) {
|
||||||
if (statusEl) statusEl.textContent = 'File too large (max 10 MB).';
|
if (statusEl) statusEl.textContent = 'File too large (max 50 MB).';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue