Merge branch 'refs/heads/schnacke' into linuxero
This commit is contained in:
@@ -56,7 +56,8 @@ class AddressDAO:
|
||||
"""
|
||||
with open("pfad zur datei", "r") as plz:
|
||||
postcodes = json.load(plz)
|
||||
irgendwas = ""
|
||||
country = "Deutschland"
|
||||
|
||||
try:
|
||||
for i in postcodes:
|
||||
test =i["plz_name"].split(",")
|
||||
@@ -66,8 +67,8 @@ class AddressDAO:
|
||||
town = town.strip()
|
||||
if town:
|
||||
print(f"PROCESSING {i['name']} {town}")
|
||||
self.__cur.callproc("addZipCodes", (i["name"], town, irgendwas,))
|
||||
#self.__cur.callproc("addZipCodes", ("56271", "Kleinmaischeid", irgendwas,))
|
||||
self.__cur.callproc("importLocation", (country, town, i["name"],))
|
||||
|
||||
except mariadb.OperationalError as e:
|
||||
print(f"Database Error: {e}")
|
||||
finally:
|
||||
|
||||
@@ -60,9 +60,12 @@ class AddressModel(QAbstractListModel):
|
||||
"""
|
||||
row = index.row()
|
||||
if role == Qt.DisplayRole:
|
||||
data = self.__address_data[row][2]
|
||||
data = self.__address_data[row][5]
|
||||
return data
|
||||
elif role == PyqcrmDataRoles.CITY_ROLE:
|
||||
data = self.__address_data[row][4]
|
||||
return data
|
||||
elif role == PyqcrmDataRoles.COUNTRY_ROLE:
|
||||
data = self.__address_data[row][3]
|
||||
return data
|
||||
return None
|
||||
@@ -74,6 +77,7 @@ class AddressModel(QAbstractListModel):
|
||||
return {
|
||||
Qt.DisplayRole: b"display",
|
||||
PyqcrmDataRoles.CITY_ROLE: b"city",
|
||||
PyqcrmDataRoles.COUNTRY_ROLE: b"country"
|
||||
}
|
||||
|
||||
def setData(self):
|
||||
|
||||
@@ -11,7 +11,6 @@ class BusinessDAO(QObject):
|
||||
__all_cols = None
|
||||
|
||||
def __init__(self):
|
||||
#print(f"*** File: {__file__}, init()")
|
||||
super().__init__()
|
||||
self.__con = DbManager().getConnection()
|
||||
if self.__con:
|
||||
@@ -22,7 +21,7 @@ class BusinessDAO(QObject):
|
||||
if self.__cur:
|
||||
self.__cur.callproc("getCustomerView", (enc_key, criterion,))
|
||||
self.__all_cols = [desc[0] for desc in self.__cur.description]
|
||||
return self.__cur.fetchall(), self.__all_cols
|
||||
return self.__cur.fetchall(), self.__all_cols
|
||||
else:
|
||||
return None, None
|
||||
except mariadb.Error as e:
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
from PySide6.QtCore import QAbstractTableModel, QModelIndex, Qt, Slot, Signal
|
||||
from .BusinessDAO import BusinessDAO
|
||||
from ..PyqcrmFlags import PyqcrmFlags
|
||||
# from ..PyqcrmFlags import PyqcrmFlags
|
||||
from ..ConfigLoader import ConfigLoader
|
||||
|
||||
# USERS TABLE
|
||||
|
||||
@@ -61,3 +61,4 @@ class ContactDAO(QObject):
|
||||
print(str(e))
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ from .DbManager import DbManager
|
||||
import json
|
||||
import mariadb
|
||||
from PySide6.QtCore import QObject, Signal
|
||||
from ..PyqcrmFlags import PyqcrmAppliEmpyFlags
|
||||
|
||||
|
||||
class EmployeeDAO(QObject):
|
||||
@@ -17,35 +16,30 @@ class EmployeeDAO(QObject):
|
||||
if self.__con:
|
||||
self.__cur = self.__con.cursor()
|
||||
|
||||
def getEmployees(self, enc_key, criterion = "Alle", processed = False, fired = False, every_state = True):
|
||||
def getEmployees(self, enc_key, criterion="Alle", processed=False, fired=False, every_state=True):
|
||||
try:
|
||||
if self.__cur:
|
||||
self.__cur.callproc("getEmployeeTable", (criterion, processed, fired, every_state, enc_key, ))
|
||||
self.__cur.callproc("getEmployeeTable", (criterion, processed, fired, every_state, enc_key,))
|
||||
self.__all_cols = [desc[0] for desc in self.__cur.description]
|
||||
return self.__cur.fetchall(), self.__all_cols
|
||||
return self.__cur.fetchall(), self.__all_cols
|
||||
else:
|
||||
return None, None
|
||||
except mariadb.Error as e:
|
||||
print(str(e))
|
||||
|
||||
def getEmployee(self, employee_id, enc_key = None):
|
||||
def getEmployee(self, employee_id, enc_key=None):
|
||||
try:
|
||||
if self.__cur:
|
||||
self.__cur.callproc("getEmployee", (employee_id, enc_key,))
|
||||
#self.__all_cols = [desc[0] for desc in self.__cur.description]
|
||||
return self.__cur.fetchall() #, self.__all_cols
|
||||
# self.__all_cols = [desc[0] for desc in self.__cur.description]
|
||||
return self.__cur.fetchall() # , self.__all_cols
|
||||
else:
|
||||
return None #, None
|
||||
return None
|
||||
except mariadb.Error as e:
|
||||
print(str(e))
|
||||
|
||||
def addEmployee(self, data, enc_key, applicant = True):
|
||||
try:
|
||||
if self.__cur:
|
||||
self.__cur.callproc("addApplicant", (json.dumps(data), applicant, enc_key,))
|
||||
self.__con.commit()
|
||||
self.newEmployeeAdded.emit(True)
|
||||
|
||||
except mariadb.Error as e:
|
||||
print(str(e))
|
||||
self.newEmployeeAdded.emit(False)
|
||||
def addEmployee(self, data, enc_key, applicant=True):
|
||||
if self.__cur:
|
||||
self.__cur.callproc("addApplicant", (json.dumps(data), applicant, enc_key,))
|
||||
self.__con.commit()
|
||||
self.newEmployeeAdded.emit(True)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
from PySide6.QtCore import QAbstractTableModel, QModelIndex, Qt, Slot, Signal
|
||||
import json
|
||||
from PySide6.QtCore import QAbstractTableModel, QModelIndex, Qt, Slot, Signal, QJsonDocument
|
||||
from PySide6.QtQml import QJSValue, QJSValueIterator
|
||||
from .EmployeeDAO import EmployeeDAO
|
||||
from ..PyqcrmFlags import PyqcrmFlags, PyqcrmAppliEmpyFlags
|
||||
# from ..PyqcrmFlags import PyqcrmFlags, PyqcrmAppliEmpyFlags
|
||||
from ..ConfigLoader import ConfigLoader
|
||||
import re
|
||||
|
||||
@@ -12,7 +14,6 @@ class EmployeeModel(QAbstractTableModel):
|
||||
__visible_index = None
|
||||
__visible_columns = None
|
||||
__col_name = ""
|
||||
__employee_dao = None
|
||||
__col_skip = 2
|
||||
__everyone = True
|
||||
|
||||
@@ -24,16 +25,39 @@ class EmployeeModel(QAbstractTableModel):
|
||||
self.__key = self.__conf['pyqcrm']['ENCRYPTION_KEY']
|
||||
self.__getData()
|
||||
|
||||
@Slot(dict, bool)
|
||||
def addEmployee(self, new_employee, applicant = True):
|
||||
@Slot(dict)
|
||||
def addEmployee(self, new_employee):
|
||||
if 'worklicense' in new_employee:
|
||||
new_employee['worklicense'] = int(new_employee['worklicense'])
|
||||
new_employee['residencetype'] = int(new_employee['residencetype'])
|
||||
self.__employee_dao.addEmployee(new_employee, self.__key, applicant)
|
||||
self.__employee_dao.addEmployee(new_employee, self.__key, False)
|
||||
|
||||
@Slot(str)
|
||||
def viewCriterion(self, criterion, processed = False, fired = False):
|
||||
self.__getData(criterion, processed, fired)
|
||||
@Slot(QJSValue)
|
||||
def addApplicant(self, new_applicant):
|
||||
data = {}
|
||||
it = QJSValueIterator(new_applicant)
|
||||
while it.hasNext():
|
||||
it.next()
|
||||
if "function" in it.value().toString() or "objectName" == it.name():
|
||||
continue
|
||||
data[it.name()] = it.value().toString()
|
||||
self.__employee_dao.addEmployee(data, self.__key)
|
||||
|
||||
# @Slot(QJSValue)
|
||||
# def addApplicant(self, applicant: QJSValue):
|
||||
# self.__employee_dao.addEmployee({
|
||||
# "city": applicant.property("city").toString(),
|
||||
# "email": applicant.property("email").toString(),
|
||||
# "firstname": applicant.property("firstname").toString(),
|
||||
# "formofaddress": applicant.property("formofaddress").toString(),
|
||||
# "houseno": applicant.property("houseno").toString(),
|
||||
# "lastname": applicant.property("lastname").toString(),
|
||||
# "mobile": applicant.property("mobile").toString(),
|
||||
# "phone": applicant.property("phone").toString(),
|
||||
# "postcode": applicant.property("postcode").toInt(),
|
||||
# "street": applicant.property("street").toString(),
|
||||
# "title": applicant.property("title").toString(),
|
||||
# }, self.__key, True)
|
||||
|
||||
@Slot(bool)
|
||||
def __refreshView(self, added):
|
||||
@@ -41,43 +65,42 @@ class EmployeeModel(QAbstractTableModel):
|
||||
self.__getData()
|
||||
self.addedNewEmployee.emit(added)
|
||||
|
||||
def __getData(self, criterion = "Alle", processed = False, fired = False, every_state = True):
|
||||
def __getData(self, criterion="Alle", processed=False, fired=False, every_state=True):
|
||||
self.beginResetModel()
|
||||
rows, self.__visible_columns = self.__employee_dao.getEmployees(self.__key, criterion, processed, fired, every_state)
|
||||
rows, self.__visible_columns = self.__employee_dao.getEmployees(self.__key, criterion, processed, fired,
|
||||
every_state)
|
||||
self.__data = rows
|
||||
self.endResetModel()
|
||||
|
||||
def rowCount(self, parent= QModelIndex()):
|
||||
return len (self.__data)
|
||||
def rowCount(self, parent=QModelIndex()):
|
||||
return len(self.__data)
|
||||
|
||||
def columnCount(self, parent= QModelIndex()):
|
||||
def columnCount(self, parent=QModelIndex()):
|
||||
return len(self.__visible_columns) - self.__col_skip
|
||||
|
||||
@Slot(str, bool, bool, bool)
|
||||
def viewCriterion(self, criterion, processed, fired, every_state):
|
||||
self.__everyone = True if criterion == 'Alle' else False
|
||||
if self.__everyone and criterion != "Alle":
|
||||
self.__col_skip = 2
|
||||
else:
|
||||
self.__col_skip = 2
|
||||
self.__getData(criterion, processed, fired, every_state)
|
||||
@Slot(str)
|
||||
def viewCriterion(self, criterion):
|
||||
self.__everyone = criterion == 'Alle'
|
||||
self.__col_skip = 2
|
||||
self.__getData(criterion, criterion == 'Erledigt', False, criterion == 'Alle')
|
||||
|
||||
def data(self, index, role= Qt.DisplayRole):
|
||||
def data(self, index, role=Qt.DisplayRole):
|
||||
if role == Qt.DisplayRole:
|
||||
row = self.__data[index.row()]
|
||||
applicant_col = index.column() + self.__col_skip
|
||||
tr = row[applicant_col] #if type(row[index.column() + 2]) is str else str(row[index.column() + 2], "utf-8")
|
||||
tr = row[
|
||||
applicant_col] # if type(row[index.column() + 2]) is str else str(row[index.column() + 2], "utf-8")
|
||||
if applicant_col == 2 and self.__everyone:
|
||||
tr = 'Ja' if tr == 1 else 'Nein'
|
||||
else:
|
||||
if tr:
|
||||
tr = re.sub("Keine Angabe ","", tr)
|
||||
#print(f"Data: {tr}")
|
||||
tr = re.sub("Keine Angabe ", "", tr)
|
||||
# print(f"Data: {tr}")
|
||||
# return row[index.column() + 2]
|
||||
return tr
|
||||
return None
|
||||
|
||||
def headerData(self, section, orientation, role = Qt.DisplayRole):
|
||||
def headerData(self, section, orientation, role=Qt.DisplayRole):
|
||||
if orientation == Qt.Horizontal and role == Qt.DisplayRole:
|
||||
self.__col_name = self.__visible_columns[section + self.__col_skip]
|
||||
return self.__col_name
|
||||
@@ -85,11 +108,11 @@ class EmployeeModel(QAbstractTableModel):
|
||||
|
||||
@Slot(int)
|
||||
def onRowClicked(self, row):
|
||||
#print(self.__data)
|
||||
# print(self.__data)
|
||||
print(f"Selected table row: {row}, corresponding DB ID: {self.__data[row][0]}")
|
||||
#if not self.__employee_dict['employee'] or self.__data[row][0] != self.__employee_dict['employee']['id']:
|
||||
#self.__employee = self.__employee_dao.getEmployee(self.__data[row][0], self.__key)
|
||||
#print(self.__business)
|
||||
#self.__getEmployeeInfo()
|
||||
# self.__getContactInfo()
|
||||
# print(self.__business_dict)
|
||||
# if not self.__employee_dict['employee'] or self.__data[row][0] != self.__employee_dict['employee']['id']:
|
||||
# self.__employee = self.__employee_dao.getEmployee(self.__data[row][0], self.__key)
|
||||
# print(self.__business)
|
||||
# self.__getEmployeeInfo()
|
||||
# self.__getContactInfo()
|
||||
# print(self.__business_dict)
|
||||
|
||||
@@ -2,7 +2,7 @@ from .DbManager import DbManager
|
||||
import json
|
||||
import mariadb
|
||||
from PySide6.QtCore import QObject, Signal
|
||||
from ..PyqcrmFlags import PyqcrmAppliEmpyFlags
|
||||
# from ..PyqcrmFlags import PyqcrmAppliEmpyFlags
|
||||
|
||||
|
||||
class ObjectDAO(QObject):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from PySide6.QtCore import QAbstractTableModel, QModelIndex, Qt, Slot, Signal
|
||||
from .ObjectDAO import ObjectDAO
|
||||
from ..PyqcrmFlags import PyqcrmFlags, PyqcrmAppliEmpyFlags
|
||||
from ..ConfigLoader import ConfigLoader
|
||||
from ..PyqcrmDataRoles import PyqcrmDataRoles
|
||||
import re
|
||||
import json
|
||||
|
||||
@@ -67,8 +67,16 @@ class ObjectModel(QAbstractTableModel):
|
||||
if object_col > 4 and tr:
|
||||
tr = re.sub("Keine Angabe ","", tr)
|
||||
return tr
|
||||
elif role == PyqcrmDataRoles.STREET_IN_POSTCODE:
|
||||
pass
|
||||
return None
|
||||
|
||||
def roleNames(self):
|
||||
return {
|
||||
Qt.DisplayRole: b"display",
|
||||
PyqcrmDataRoles.STREET_IN_POSTCODE: b"StreetInPostcode",
|
||||
}
|
||||
|
||||
def headerData(self, section, orientation, role = Qt.DisplayRole):
|
||||
if orientation == Qt.Horizontal and role == Qt.DisplayRole:
|
||||
self.__col_name = self.__visible_columns[section + self.__col_skip]
|
||||
|
||||
Reference in New Issue
Block a user