Fix adding a contact person to an object and db autocommit
This commit is contained in:
@@ -22,8 +22,13 @@ class ContactDAO(QObject):
|
||||
if self.__cur:
|
||||
self.__cur.callproc("addContactPerson", (enc_key, json.dumps(contact),))
|
||||
self.__con.commit()
|
||||
self.__cur.callproc("getLastInsertId")
|
||||
contact_id = self.__cur.fetchone()
|
||||
self.__cur.callproc("logger",(contact_id[0], "INSERT", "addContactPerson: New Contact added",))
|
||||
self.__con.commit()
|
||||
return contact_id[0]
|
||||
else:
|
||||
return None
|
||||
except mariadb.Error as e:
|
||||
print("MDB: " + str(e))
|
||||
except Exception as e:
|
||||
@@ -36,7 +41,7 @@ class ContactDAO(QObject):
|
||||
self.__con.commit()
|
||||
self.__cur.callproc("logObjectContact")
|
||||
self.__con.commit()
|
||||
self.newObjectContactAdded.emit(True)
|
||||
# self.newObjectContactAdded.emit(True)
|
||||
except mariadb.Error as e:
|
||||
print("MDB (addObjectContact): " + str(e))
|
||||
self.newObjectContactAdded.emit(False)
|
||||
|
||||
@@ -37,7 +37,7 @@ class DbManager():
|
||||
def __initializeConfig(cls, dbconf):
|
||||
cls.__con_param = { 'user': dbconf['DB_USER'], 'password': dbconf['DB_PASS'],
|
||||
'port': int (dbconf['DB_PORT']), 'host': dbconf['DB_HOST'],
|
||||
'database': dbconf['DB_NAME'], 'connect_timeout': 5
|
||||
'database': dbconf['DB_NAME'], 'connect_timeout': 5, 'autocommit': True,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class ObjectDAO(QObject):
|
||||
else:
|
||||
return None
|
||||
except mariadb.Error as e:
|
||||
self.newObjectAdded.emit(False)
|
||||
self.newObjectAdded.emit(False, None)
|
||||
print(str(e))
|
||||
|
||||
def getObjects(self, criterion, enc_key = None):
|
||||
|
||||
@@ -7,6 +7,7 @@ import json
|
||||
|
||||
class ObjectModel(QAbstractTableModel):
|
||||
objectAdded = Signal(bool, int)
|
||||
objectIdReady = Signal(int)
|
||||
|
||||
__data = None
|
||||
__object_dao = None
|
||||
@@ -32,6 +33,7 @@ class ObjectModel(QAbstractTableModel):
|
||||
#print(new_object)
|
||||
|
||||
o = self.__object_dao.addObject(new_object)
|
||||
self.objectIdReady.emit(o)
|
||||
|
||||
# @Slot(str)
|
||||
# def viewCriterion(self, criterion, processed = False, fired = False):
|
||||
@@ -55,7 +57,6 @@ class ObjectModel(QAbstractTableModel):
|
||||
|
||||
@Slot(str)
|
||||
def viewCriterion(self, criterion):
|
||||
print(f"Criterion: {criterion}")
|
||||
self.__getData(criterion)
|
||||
|
||||
def data(self, index, role= Qt.DisplayRole):
|
||||
|
||||
Reference in New Issue
Block a user