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.
This commit is contained in:
parent
418dce95db
commit
d61bfafe5c
@ -1,4 +1,5 @@
|
|||||||
2.6
|
2.6
|
||||||
|
- Improved survey sending
|
||||||
|
|
||||||
2.5
|
2.5
|
||||||
- Add new class of tests for queries that are supposed to fail
|
- Add new class of tests for queries that are supposed to fail
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# Relational
|
# 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
|
# Relation is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# 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
|
from relational.rtypes import is_valid_relation_name
|
||||||
|
|
||||||
|
|
||||||
|
SWEARWORDS = {'fuck', 'shit', 'suck', 'merda', 'mierda', 'merde'}
|
||||||
|
|
||||||
|
|
||||||
def send_survey(data):
|
def send_survey(data):
|
||||||
'''Sends the survey. Data must be a dictionary.
|
'''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 = ''
|
post = ''
|
||||||
for i in data.keys():
|
for i in data.keys():
|
||||||
post += '%s: %s\n' % (i, data[i].strip())
|
post += '%s: %s\n' % (i, data[i].strip())
|
||||||
|
|
||||||
|
lowpost = post.lower()
|
||||||
|
for i in SWEARWORDS:
|
||||||
|
if i in lowpost:
|
||||||
|
return -1
|
||||||
|
|
||||||
# sends the string
|
# sends the string
|
||||||
params = urllib.parse.urlencode({'survey': post})
|
params = urllib.parse.urlencode({'survey': post})
|
||||||
headers = {"Content-type":
|
headers = {"Content-type":
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# Relational
|
# 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
|
# Relational is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# 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)
|
response = maintenance.send_survey(post)
|
||||||
|
|
||||||
if response != 200:
|
if response == 200:
|
||||||
QtWidgets.QMessageBox.information(None, QtWidgets.QApplication.translate(
|
|
||||||
"Form", "Error"), QtWidgets.QApplication.translate("Form", "Unable to send the data!"))
|
|
||||||
else:
|
|
||||||
QtWidgets.QMessageBox.information(None, QtWidgets.QApplication.translate(
|
QtWidgets.QMessageBox.information(None, QtWidgets.QApplication.translate(
|
||||||
"Form", "Thanks"), QtWidgets.QApplication.translate("Form", "Thanks for sending!"))
|
"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()
|
self.hide()
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# Relational
|
# 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
|
# Relational is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -148,7 +148,9 @@ def survey():
|
|||||||
for i in fields:
|
for i in fields:
|
||||||
a = input('%s: ' % i)
|
a = input('%s: ' % i)
|
||||||
post[i] = a
|
post[i] = a
|
||||||
maintenance.send_survey(post)
|
response = maintenance.send_survey(post)
|
||||||
|
if response == -1:
|
||||||
|
print('Yeah, not sending that.')
|
||||||
|
|
||||||
|
|
||||||
def help(command):
|
def help(command):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user