- Fixed duplicate image uploading bug (i think)
- changing community settings now redirects you, same with creating a community.
This commit is contained in:
some weird guy
2023-09-04 21:17:50 -07:00
parent b4772d0e20
commit a9bf3179f1
3 changed files with 23 additions and 13 deletions
+12 -3
View File
@@ -50,15 +50,24 @@ def compress_and_resize_content(image):
# I do want to move each and every form over to here. Not only will this trivialize making new forms, this will also make it more secure or something.
class CommunitySettingForm(forms.ModelForm):
description = forms.CharField(max_length = 2200,required=False, widget=forms.Textarea(attrs={'class': 'textarea'}))
def __init__(self, *args, **kwargs):
super(CommunitySettingForm, self).__init__(*args, **kwargs)
# Store the initial values of the image fields
self.initial_ico = self.instance.ico
self.initial_banner = self.instance.banner
def clean_ico(self):
ico = self.cleaned_data.get('ico')
if ico:
# Check if the image has changed
if ico and ico != self.initial_ico:
return compress_and_resize_icon(image=ico)
return ico
def clean_banner(self):
def clean_banner(self):
banner = self.cleaned_data.get('banner')
if banner:
# Check if the image has changed
if banner and banner != self.initial_banner:
return compress_and_resize_content(image=banner)
return banner