summaryrefslogtreecommitdiffstats
path: root/activities/views
diff options
context:
space:
mode:
authorAvi Flax2022-12-04 20:20:50 -0500
committerGitHub2022-12-04 18:20:50 -0700
commit4493eefb768dac16500a888d2e8b868b1457655f (patch)
tree60ec292f609f860369d6df401c04488a9e3669f3 /activities/views
parent3f8045f4128d14558636b1c8a9445c29e8e1583d (diff)
downloadtakahe-4493eefb768dac16500a888d2e8b868b1457655f.tar.gz
takahe-4493eefb768dac16500a888d2e8b868b1457655f.tar.bz2
takahe-4493eefb768dac16500a888d2e8b868b1457655f.zip
Make max media upload size configurable
Diffstat (limited to 'activities/views')
-rw-r--r--activities/views/compose.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/activities/views/compose.py b/activities/views/compose.py
index d5d034b..313fe74 100644
--- a/activities/views/compose.py
+++ b/activities/views/compose.py
@@ -1,4 +1,5 @@
from django import forms
+from django.conf import settings
from django.core.exceptions import PermissionDenied
from django.shortcuts import get_object_or_404, redirect, render
from django.utils.decorators import method_decorator
@@ -158,10 +159,12 @@ class ImageUpload(FormView):
def clean_image(self):
value = self.cleaned_data["image"]
- if value.size > 1024 * 1024 * 10:
+ max_mb = settings.SETUP.MEDIA_MAX_IMAGE_FILESIZE_MB
+ max_bytes = max_mb * 1024 * 1024
+ if value.size > max_bytes:
# Erase the file from our data to stop trying to show it again
self.files = {}
- raise forms.ValidationError("File must be 10MB or less")
+ raise forms.ValidationError(f"File must be {max_mb}MB or less")
return value
def form_invalid(self, form):