def debates_badwords(): if request.method == 'POST': new_words = request.form.get('badwords', settings.get_bad_words()) settings.set_bad_words(new_words) flash('Bad words updated successfully.', 'info') return render_template('admin/debates/badwords.html', badwords=settings.get_bad_words(), section_selector='debates', page_selector='badwords')
def has_bad_words(content): word_list = settings.get_bad_words().lower().split(" ") content_words = content.lower().split(" ") # remove special chars from submitted content to_compare = [] for word in content_words: to_compare.append(''.join(e for e in word if e.isalnum())) for word in word_list: if word in to_compare: current_app.logger.debug("Found bad word: %s" % word) return True return False
def bad_words(): return jsonify({ "words": settings.get_bad_words().split() })