Update ticket lastresponse in post_response()

Addesses issue #14
This commit is contained in:
2Shirt 2022-02-20 17:10:47 -07:00
parent 147c35f0c6
commit 746be1d2d7
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -198,6 +198,7 @@ class osTicket(): # pylint: disable=invalid-name
def post_response(self, response, color='Normal'):
"""Post a reply to a ticket in osTicket."""
cur_date_time = time.strftime('%Y-%m-%d %H:%M:%S')
lines = []
test_station = get_test_station_name()
self._connect(silent=True)
@ -227,7 +228,7 @@ class osTicket(): # pylint: disable=invalid-name
f" '{STAFF['ID']}',"
f" '{STAFF['Name']}',"
f" '{response}',"
f" '{time.strftime('%Y-%m-%d %H:%M:%S')}',"
f" '{cur_date_time}',"
f" '{RESPONSE_COLOR_CODES.get(color, 'Normal')}'"
f");"
)
@ -238,6 +239,17 @@ class osTicket(): # pylint: disable=invalid-name
except mariadb.errors.Error:
self.errors = True
# Update ticket last repsonse field
sql_cmd = (
f"UPDATE `{SQL['DB']}`.`{TABLE_TICKET}`"
f"SET `lastresponse` = '{cur_date_time}' "
f"WHERE `{TABLE_TICKET}`.`ticket_id` = {self.ticket_id};"
)
try:
self.db_cursor.execute(sql_cmd)
except mariadb.errors.Error:
self.errors = True
# Done
self._disconnect()