clean_up done

This commit is contained in:
Kostiantyn Stoliarskyi 2023-05-25 17:22:56 +03:00
parent c82f90c6fb
commit 377c3f0092
3 changed files with 17 additions and 2 deletions

View File

@ -1,7 +1,10 @@
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField
from wtforms import StringField, SubmitField, ValidationError
from wtforms.validators import DataRequired
from app.controllers import clean_html
from app.logger import log
class BaseInterpretationForm(FlaskForm):
about = StringField("About")
@ -12,6 +15,14 @@ class CreateInterpretationForm(BaseInterpretationForm):
section_id = StringField("Interpretation ID", [DataRequired()])
submit = SubmitField("Create")
def validate_text(self, field):
text = clean_html(field.data)
text = text.replace(" ", "")
text = text.strip()
if len(text) < 1:
log(log.WARNING, "Can't submit empty interpretation")
raise ValidationError("You can't create interpretation with no text")
class EditInterpretationForm(BaseInterpretationForm):
interpretation_id = StringField("Interpretation ID", [DataRequired()])

File diff suppressed because one or more lines are too long

View File

@ -46,6 +46,10 @@ export function addSection() {
`${collectionId}/${subCollectionId}/create_section`,
);
}
if (newActionPath.includes('/0')) {
console.log('ALERT');
return;
}
addSectionForm.setAttribute('action', `${newActionPath}`);
sectionModal.show();