mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-01-26 22:49:01 -06:00
Fix this too
This commit is contained in:
@@ -156,6 +156,19 @@ class ShareLinkBundleAPITests(DirectoriesMixin, APITestCase):
|
|||||||
|
|
||||||
self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED)
|
self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED)
|
||||||
|
|
||||||
|
def test_download_failed_bundle_returns_503(self):
|
||||||
|
bundle = ShareLinkBundle.objects.create(
|
||||||
|
slug="failedslug",
|
||||||
|
file_version=ShareLink.FileVersion.ARCHIVE,
|
||||||
|
status=ShareLinkBundle.Status.FAILED,
|
||||||
|
)
|
||||||
|
bundle.documents.set([self.document])
|
||||||
|
|
||||||
|
self.client.logout()
|
||||||
|
response = self.client.get(f"/share/{bundle.slug}/")
|
||||||
|
|
||||||
|
self.assertEqual(response.status_code, status.HTTP_503_SERVICE_UNAVAILABLE)
|
||||||
|
|
||||||
def test_expired_share_link_redirects(self):
|
def test_expired_share_link_redirects(self):
|
||||||
share_link = ShareLink.objects.create(
|
share_link = ShareLink.objects.create(
|
||||||
slug="expiredlink",
|
slug="expiredlink",
|
||||||
|
|||||||
@@ -2939,16 +2939,10 @@ class SharedLinkView(View):
|
|||||||
if bundle.expiration is not None and bundle.expiration < timezone.now():
|
if bundle.expiration is not None and bundle.expiration < timezone.now():
|
||||||
return HttpResponseRedirect("/accounts/login/?sharelink_expired=1")
|
return HttpResponseRedirect("/accounts/login/?sharelink_expired=1")
|
||||||
|
|
||||||
file_path = bundle.absolute_file_path
|
if bundle.status in {
|
||||||
|
|
||||||
if (
|
|
||||||
bundle.status
|
|
||||||
in {
|
|
||||||
ShareLinkBundle.Status.PENDING,
|
ShareLinkBundle.Status.PENDING,
|
||||||
ShareLinkBundle.Status.PROCESSING,
|
ShareLinkBundle.Status.PROCESSING,
|
||||||
}
|
}:
|
||||||
or file_path is None
|
|
||||||
):
|
|
||||||
return HttpResponse(
|
return HttpResponse(
|
||||||
_(
|
_(
|
||||||
"The share link bundle is still being prepared. Please try again later.",
|
"The share link bundle is still being prepared. Please try again later.",
|
||||||
@@ -2956,7 +2950,9 @@ class SharedLinkView(View):
|
|||||||
status=status.HTTP_202_ACCEPTED,
|
status=status.HTTP_202_ACCEPTED,
|
||||||
)
|
)
|
||||||
|
|
||||||
if bundle.status == ShareLinkBundle.Status.FAILED:
|
file_path = bundle.absolute_file_path
|
||||||
|
|
||||||
|
if bundle.status == ShareLinkBundle.Status.FAILED or file_path is None:
|
||||||
return HttpResponse(
|
return HttpResponse(
|
||||||
_(
|
_(
|
||||||
"The share link bundle is unavailable.",
|
"The share link bundle is unavailable.",
|
||||||
|
|||||||
Reference in New Issue
Block a user