def check( self ): errors = [] if self.title.strip() == "": errors.append( _("Abstract title cannot be empty") ) for f in self._afm.getFields(): id = f.getId() caption = f.getCaption() ml = f.getMaxLength() limitation = f.getLimitation() if f.isActive() and f.isMandatory() and self._otherFields.get(id,"") == "": errors.append(_("The field '%s' is mandatory") % caption) if ml != 0: if limitation == "words" and textUtils.wordsCounter(self._otherFields.get(id,"")) > ml: errors.append(_("The field '%s' cannot be more than %s words") % (caption,ml)) elif limitation == "chars" and len(self._otherFields.get(id,"")) > ml: errors.append(_("The field '%s' cannot be more than %s characters") % (caption,ml)) if not self.origin == "management": if not self._prAuthorsListParam: errors.append( _("No primary author has been specified. You must define at least one primary author") ) if not self._checkSpeaker() and self._absMgr.showSelectAsSpeaker() and self._absMgr.isSelectSpeakerMandatory(): errors.append( _("At least one presenter must be specified") ) if not self.tracks and self._absMgr.areTracksMandatory(): # check if there are tracks, otherwise the user cannot select at least one if len(self._absMgr.getConference().getTrackList()) != 0: errors.append( _("At least one track must be seleted") ) if self._hasExceededTotalSize(): errors.append(_("The maximum size allowed for the attachments (%sMB) has been exceeded.") % Config.getInstance().getMaxUploadFilesTotalSize()) return errors
def check(self, content): errors = super(AbstractTextFieldWrapper, self).check(content) if self.max_words and wordsCounter(str(content)) > self.max_words: errors.append(_("The field '{}' cannot be more than {} words long").format( self.field.title, self.max_words)) elif self.max_length and len(content) > self.max_length: errors.append(_("The field '{}' cannot be more than {} characters long").format( self.field.title, self.max_length)) return errors