Skip to content

Commit

Permalink
Server: Check user input for copter name
Browse files Browse the repository at this point in the history
  • Loading branch information
goldarte committed Oct 21, 2019
1 parent eb61fd0 commit 8b39864
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions Server/copter_table_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,16 @@ def setData(self, index, value, role=Qt.EditRole):
if role == Qt.CheckStateRole:
self.data_contents[row].states.checked = value
elif role == Qt.EditRole: # For user actions with data
if col == 0: # and self.on_id_changed:
#self.data_contents[row][col] = "Awaiting for response"
#self.data_contents[row].states.copter_id = None

self.data_contents[row].client.send_message("id", {"new_id": value})
self.data_contents[row].client.remove()
if col == 0:
# check user hostname spelling http://man7.org/linux/man-pages/man7/hostname.7.html
if value[0] != '-' and len(value) <= 63 and re.match("^[A-Za-z0-9-]*$", value):
self.data_contents[row].client.send_message("id", {"new_id": value})
self.data_contents[row].client.remove()
else:
msg = QtWidgets.QMessageBox()
msg.setIcon(QtWidgets.QMessageBox.Critical)
msg.setText("Wrong input for the copter name!\nPlease use only A-Z, a-z, 0-9, and '-' chars.\nDon't use '-' as first char.")
msg.exec_()
else:
self.data_contents[row][col] = value

Expand Down

0 comments on commit 8b39864

Please sign in to comment.