mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-11-16 09:34:03 +01:00
better file download handling
This commit is contained in:
@@ -291,7 +291,7 @@ class IdPossibleActionsSerializer(serializers.Serializer):
|
||||
name = serializers.CharField()
|
||||
icon = serializers.CharField()
|
||||
label = serializers.CharField()
|
||||
url = serializers.URLField()
|
||||
body = serializers.DictField()
|
||||
|
||||
|
||||
class IdentitySerializer(serializers.Serializer):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""PDF Credentials API v2 views."""
|
||||
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.http import HttpResponse
|
||||
from django.http import HttpResponse
|
||||
|
||||
from rest_framework import permissions
|
||||
from rest_framework.views import APIView
|
||||
@@ -33,7 +33,7 @@ class PDFCredentialView(APIView):
|
||||
content = serializer.context["content"]
|
||||
fname = serializer.context["fname"]
|
||||
resp = HttpResponse(content)
|
||||
resp["Content-Type"] = "application/pdf"
|
||||
resp["Content-Type"] = "application/pdf;base64"
|
||||
resp["Content-Length"] = len(content)
|
||||
resp["Content-Disposition"] = f"attachment; filename={fname};"
|
||||
return resp
|
||||
|
||||
@@ -65,8 +65,7 @@ def extra_identities_actions(sender, account, **kwargs):
|
||||
return []
|
||||
return {
|
||||
"name": "get_credentials",
|
||||
"url": reverse("v2:get-credentials",
|
||||
args=[account.id]),
|
||||
"body": {"type": "pdfcredentials"},
|
||||
"icon": "mdi-file-download-outline",
|
||||
"label": _("Download PDF credentials")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user