diff --git a/CHANGELOG b/CHANGELOG index 4ae9362..d84f0ee 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ 2.6 +- Improved survey sending 2.5 - Add new class of tests for queries that are supposed to fail diff --git a/relational/maintenance.py b/relational/maintenance.py index 9351860..89b2229 100644 --- a/relational/maintenance.py +++ b/relational/maintenance.py @@ -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": diff --git a/relational_gui/surveyForm.py b/relational_gui/surveyForm.py index 64c77e0..647b3ca 100644 --- a/relational_gui/surveyForm.py +++ b/relational_gui/surveyForm.py @@ -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() diff --git a/relational_readline/linegui.py b/relational_readline/linegui.py index 2b4c8ed..23a57b2 100644 --- a/relational_readline/linegui.py +++ b/relational_readline/linegui.py @@ -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):