Do not send survey in case of swearwords

I'm getting tired of kids blaming their idiocy on me.

They can go begging for money, for all I care.
master
Salvo 'LtWorf' Tomaselli 2017-05-10 22:07:52 +07:00
parent 418dce95db
commit d61bfafe5c
No known key found for this signature in database
GPG Key ID: B3A7CF0C801886CF
4 changed files with 26 additions and 9 deletions

@ -1,4 +1,5 @@
2.6
- Improved survey sending
2.5
- Add new class of tests for queries that are supposed to fail

@ -1,5 +1,5 @@
# Relational
# Copyright (C) 2008-2016 Salvo "LtWorf" Tomaselli
# Copyright (C) 2008-2017 Salvo "LtWorf" Tomaselli
#
# Relation is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -29,14 +29,25 @@ from relational import parser
from relational.rtypes import is_valid_relation_name
SWEARWORDS = {'fuck', 'shit', 'suck', 'merda', 'mierda', 'merde'}
def send_survey(data):
'''Sends the survey. Data must be a dictionary.
returns the http response'''
returns the http response.
returns 0 in case of error
returns -1 in case of swearwords'''
post = ''
for i in data.keys():
post += '%s: %s\n' % (i, data[i].strip())
lowpost = post.lower()
for i in SWEARWORDS:
if i in lowpost:
return -1
# sends the string
params = urllib.parse.urlencode({'survey': post})
headers = {"Content-type":

@ -1,5 +1,5 @@
# Relational
# Copyright (C) 2008-2016 Salvo "LtWorf" Tomaselli
# Copyright (C) 2008-2017 Salvo "LtWorf" Tomaselli
#
# Relational is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -82,11 +82,14 @@ class surveyForm (QtWidgets.QWidget):
response = maintenance.send_survey(post)
if response != 200:
QtWidgets.QMessageBox.information(None, QtWidgets.QApplication.translate(
"Form", "Error"), QtWidgets.QApplication.translate("Form", "Unable to send the data!"))
else:
if response == 200:
QtWidgets.QMessageBox.information(None, QtWidgets.QApplication.translate(
"Form", "Thanks"), QtWidgets.QApplication.translate("Form", "Thanks for sending!"))
elif response == -1:
QtWidgets.QMessageBox.information(None, QtWidgets.QApplication.translate(
"Form", "Seriously?"), QtWidgets.QApplication.translate("Form", "Yeah, not sending that."))
else:
QtWidgets.QMessageBox.information(None, QtWidgets.QApplication.translate(
"Form", "Error"), QtWidgets.QApplication.translate("Form", "Unable to send the data!"))
self.hide()

@ -1,5 +1,5 @@
# Relational
# Copyright (C) 2010-2016 Salvo "LtWorf" Tomaselli
# Copyright (C) 2010-2017 Salvo "LtWorf" Tomaselli
#
# Relational is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -148,7 +148,9 @@ def survey():
for i in fields:
a = input('%s: ' % i)
post[i] = a
maintenance.send_survey(post)
response = maintenance.send_survey(post)
if response == -1:
print('Yeah, not sending that.')
def help(command):