def validate_alias(form, field): if form.alias.data == 'new': raise wtforms.ValidationError(flask.Markup( 'The alias cannot be <code>new</code>.')) check = Election.search(SESSION, alias=form.alias.data) if check: if not (form._election_id and form._election_id == check[0].id): raise wtforms.ValidationError( 'There is already another election with this alias.')
def validate_shortdesc(form, field): check = Election.search(SESSION, shortdesc=form.shortdesc.data) if check: if not (form._election_id and form._election_id == check[0].id): raise wtforms.ValidationError( 'There is already another election with this summary.')