How to use the spam.is_spam function in spam

To help you get started, we’ve selected a few spam examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CityOfNewYork / NYCOpenRecords / public_records_portal / views.py View on Github external
@app.route("/public_add_a_", methods = ["GET", "POST"])
def public_add_a_resource(resource, passed_recaptcha = False, data = None):
	if (data or request.method == 'POST') and ('note' in resource or 'subscriber' in resource):
			if not data:
					data = request.form.copy()
			if 'note' in resource:
				if not passed_recaptcha and is_spam(comment = data['note_text'], user_ip = request.remote_addr, user_agent = request.headers.get('User-Agent')):
					return render_template('recaptcha_note.html', form = data, message = "Hmm, your note looks like spam. To submit your note, type the numbers or letters you see in the field below.")
				resource_id = prr.add_note(request_id = data['request_id'], text = data['note_text'], passed_spam_filter = True)
			else:
				resource_id = prr.add_resource(resource = resource, request_body = data, current_user_id = None)
			if type(resource_id) == int:
				request_id = data['request_id']
				audience = 'public'
				if 'subscriber' in resource:
					audience = 'follower'
				return redirect(url_for('show_request_for_x', audience=audience, request_id = request_id))
	return render_template('error.html')
github CityOfNewYork / NYCOpenRecords / public_records_portal / views.py View on Github external
@app.route("/new", methods=["GET", "POST"])
def new_request(passed_recaptcha = False, data = None):
	if data or request.method == 'POST':
		if not data and not passed_recaptcha:
			data = request.form.copy()
		email = data['request_email']
		request_text = data['request_text']
		if request_text == "":
			return render_template('error.html', message = "You cannot submit an empty request.")
		if email == "" and 'ignore_email' not in data and not passed_recaptcha:
			return render_template('missing_email.html', form = data)
		if not passed_recaptcha and (is_spam(comment = request_text, user_ip = request.remote_addr, user_agent = request.headers.get('User-Agent'))):
			return render_template('recaptcha_request.html', form = data, message = "Hmm, your request looks like spam. To submit your request, type the numbers or letters you see in the field below.")

		alias = None
		phone = None
		offline_submission_type = None
		date_received = None
		department = None
		if 'request_department' in data:
			department = data['request_department']
		if 'request_alias' in data:
			alias = data['request_alias']
		if 'request_phone' in data:
			phone = data['request_phone']
		if 'format_received' in data:
			offline_submission_type = data['format_received']
		if 'date_received' in data: # From the jQuery datepicker
github CityOfNewYork / NYCOpenRecords / public_records_portal / views.py View on Github external
@app.route("/update_a_", methods = ["GET", "POST"])
def update_a_resource(resource, passed_recaptcha = False, data = None):
	if (data or request.method == 'POST'):
		if not data:
			data = request.form.copy()
		if 'qa' in resource:
			if not passed_recaptcha and is_spam(comment = data['answer_text'], user_ip = request.remote_addr, user_agent = request.headers.get('User-Agent')):
				return render_template('recaptcha_answer.html', form = data, message = "Hmm, your answer looks like spam. To submit your answer, type the numbers or letters you see in the fiel dbelow.")
			prr.answer_a_question(qa_id = int(data['qa_id']), answer = data['answer_text'], passed_spam_filter = True)
		else:
			update_resource(resource, data)
		if current_user.is_anonymous() == False:
			return redirect(url_for('show_request_for_city', request_id = request.form['request_id']))
		else:
			return redirect(url_for('show_request', request_id = request.form['request_id']))
	return render_template('error.html', message = "You can only update requests from a request page!")
github codeforamerica / recordtrac / public_records_portal / views.py View on Github external
@app.route("/new", methods=["GET", "POST"])
def new_request(passed_recaptcha = False, data = None):
	if data or request.method == 'POST':
		if not data and not passed_recaptcha:
			data = request.form.copy()
		email = data['request_email']
		request_text = data['request_text']
		if request_text == "":
			return render_template('error.html', message = "You cannot submit an empty request.")
		if email == "" and 'ignore_email' not in data and not passed_recaptcha:
			return render_template('missing_email.html', form = data)
		if not passed_recaptcha and (is_spam(comment = request_text, user_ip = request.remote_addr, user_agent = request.headers.get('User-Agent'))):
			return render_template('recaptcha_request.html', form = data, message = "Hmm, your request looks like spam. To submit your request, type the numbers or letters you see in the field below.")

		alias = None
		phone = None
		offline_submission_type = None
		date_received = None
		department = None
		if 'request_department' in data:
			department = data['request_department']
		if 'request_alias' in data:
			alias = data['request_alias']
		if 'request_phone' in data:
			phone = data['request_phone']
		if 'format_received' in data:
			offline_submission_type = data['format_received']
		if 'date_received' in data: # From the jQuery datepicker
github codeforamerica / recordtrac / public_records_portal / views.py View on Github external
@app.route("/update_a_", methods = ["GET", "POST"])
def update_a_resource(resource, passed_recaptcha = False, data = None):
	if (data or request.method == 'POST'):
		if not data:
			data = request.form.copy()
		if 'qa' in resource:
			if not passed_recaptcha and is_spam(comment = data['answer_text'], user_ip = request.remote_addr, user_agent = request.headers.get('User-Agent')):
				return render_template('recaptcha_answer.html', form = data, message = "Hmm, your answer looks like spam. To submit your answer, type the numbers or letters you see in the fiel dbelow.")
			prr.answer_a_question(qa_id = int(data['qa_id']), answer = data['answer_text'], passed_spam_filter = True)
		else:
			update_resource(resource, data)
		if current_user.is_anonymous() == False:
			return redirect(url_for('show_request_for_city', request_id = request.form['request_id']))
		else:
			return redirect(url_for('show_request', request_id = request.form['request_id']))
	return render_template('error.html', message = "You can only update requests from a request page!")
github codeforamerica / recordtrac / public_records_portal / views.py View on Github external
@app.route("/public_add_a_", methods = ["GET", "POST"])
def public_add_a_resource(resource, passed_recaptcha = False, data = None):
	if (data or request.method == 'POST') and ('note' in resource or 'subscriber' in resource):
			if not data:
					data = request.form.copy()
			if 'note' in resource:
				if not passed_recaptcha and is_spam(comment = data['note_text'], user_ip = request.remote_addr, user_agent = request.headers.get('User-Agent')):
					return render_template('recaptcha_note.html', form = data, message = "Hmm, your note looks like spam. To submit your note, type the numbers or letters you see in the field below.")
				resource_id = prr.add_note(request_id = data['request_id'], text = data['note_text'], passed_spam_filter = True)
			else:
				resource_id = prr.add_resource(resource = resource, request_body = data, current_user_id = None)
			if type(resource_id) == int:
				request_id = data['request_id']
				audience = 'public'
				if 'subscriber' in resource:
					audience = 'follower'
				return redirect(url_for('show_request_for_x', audience=audience, request_id = request_id))
	return render_template('error.html')