浏览代码

Story 671: Remove legacy document hook (#674)

Remove a legacy wagtail_hook that was fixing an issue that no longer
exists and was now causing problems.

closes #671
Jeremy Childers 1 月之前
父节点
当前提交
a92089e44d
共有 2 个文件被更改,包括 6 次插入24 次删除
  1. 6 6
      coderedcms/models/integration_models.py
  2. 0 18
      coderedcms/wagtail_hooks.py

+ 6 - 6
coderedcms/models/integration_models.py

@@ -95,14 +95,14 @@ class MailchimpSubscriberIntegrationWidget(Input):
                 }
 
                 list_library[mlist["id"]]["merge_fields"] = (
-                    mailchimp.get_merge_fields_for_list(
-                        mlist["id"]
-                    )["merge_fields"]
+                    mailchimp.get_merge_fields_for_list(mlist["id"])[
+                        "merge_fields"
+                    ]
                 )
                 list_library[mlist["id"]]["interest_categories"] = (
-                    mailchimp.get_interest_categories_for_list(
-                        mlist["id"]
-                    )["categories"]
+                    mailchimp.get_interest_categories_for_list(mlist["id"])[
+                        "categories"
+                    ]
                 )
 
                 for category in list_library[mlist["id"]][

+ 0 - 18
coderedcms/wagtail_hooks.py

@@ -1,7 +1,4 @@
-import mimetypes
-
 from django.contrib.contenttypes.models import ContentType
-from django.http.response import HttpResponse
 from django.templatetags.static import static
 from django.urls import reverse
 from django.utils.html import format_html
@@ -105,21 +102,6 @@ def crx_forms(user, editable_forms):
     return editable_forms
 
 
-@hooks.register("before_serve_document")
-def serve_document_directly(document, request):
-    """
-    This hook prevents documents from being downloaded unless
-    specified by an <a> tag with the download attribute.
-    """
-    content_type, content_encoding = mimetypes.guess_type(document.filename)
-    response = HttpResponse(document.file.read(), content_type=content_type)
-    response["Content-Disposition"] = 'inline;filename="{0}"'.format(
-        document.filename
-    )
-    response["Content-Encoding"] = content_encoding
-    return response
-
-
 class ImportExportMenuItem(MenuItem):
     def is_shown(self, request):
         return request.user.is_superuser