diff --git a/scripts/wk/osticket.py b/scripts/wk/osticket.py index bd13fafa..c38be02e 100644 --- a/scripts/wk/osticket.py +++ b/scripts/wk/osticket.py @@ -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()