Skip to content

Commit

Permalink
Remove download file-size limits
Browse files Browse the repository at this point in the history
  • Loading branch information
haydngreatnews committed Jul 24, 2024
1 parent 242c094 commit e3c4a81
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions cdhweb/pages/blocks/download_block.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,15 @@
from django.core.exceptions import ValidationError
from wagtail import blocks
from wagtail.documents.blocks import DocumentChooserBlock


class LimitedDocumentChooserBlock(DocumentChooserBlock):
def clean(self, value):
document = super().clean(value)
max_file_size = 5 * 1024 * 1024 # 5 MB

# Check if the file size exceeds the limit
if document.file_size > max_file_size:
raise ValidationError("File size exceeds the limit of 5 MB.")

return document


class FileBlock(blocks.StructBlock):
title = blocks.CharBlock(
help_text="Title for this file as you'd like it to be seen by the public. It will fall back to document title if this field is empty",
label="Customised File Title",
required=False,
)

file = LimitedDocumentChooserBlock(
file = DocumentChooserBlock(
verbose_name="Document",
required=True,
)
Expand Down

0 comments on commit e3c4a81

Please sign in to comment.