fix(profile): remove carriage returns from biographies on save

This commit is contained in:
Shreyas Mayya 2022-03-21 08:59:10 -04:00
parent 8694e25247
commit e9fc4261b7
No known key found for this signature in database
GPG Key ID: 42522E3641BA2E31

View File

@ -24,6 +24,17 @@ class ProfilePublishForm(forms.ModelForm):
) )
def clean(self) -> Dict[str, Any]: def clean(self) -> Dict[str, Any]:
data = self.data.copy()
# Remove carriage returns from biography
if data.get("biography"):
data["biography"] = data["biography"].replace("\r", "")
self.instance.biography = data["biography"]
if len(data["biography"]) <= self.fields["biography"].max_length:
if self.errors.get("biography"):
del self.errors["biography"]
self.data = data
cleaned_data = super().clean() cleaned_data = super().clean()
# Check the GPA: 0.0 <= GPA <= 5.0 # Check the GPA: 0.0 <= GPA <= 5.0