Compare commits
3 Commits
5b16432767
...
feature/ap
| Author | SHA256 | Date | |
|---|---|---|---|
|
|
76fdc880c7 | ||
|
|
45f19d80d0 | ||
|
|
0ae153617b |
12
.idea/dataSources.xml
generated
Normal file
12
.idea/dataSources.xml
generated
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||||
|
<data-source source="LOCAL" name="pyqcrm@bearybot.selfhost.co" uuid="ed28331b-481b-40e7-9295-d9cdae9fd4f2">
|
||||||
|
<driver-ref>mariadb</driver-ref>
|
||||||
|
<synchronize>true</synchronize>
|
||||||
|
<jdbc-driver>org.mariadb.jdbc.Driver</jdbc-driver>
|
||||||
|
<jdbc-url>jdbc:mariadb://bearybot.selfhost.co:8080/pyqcrm</jdbc-url>
|
||||||
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
|
</data-source>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/inspectionProfiles/Project_Default.xml
generated
6
.idea/inspectionProfiles/Project_Default.xml
generated
@@ -1,6 +0,0 @@
|
|||||||
<component name="InspectionProjectProfileManager">
|
|
||||||
<profile version="1.0">
|
|
||||||
<option name="myName" value="Project Default" />
|
|
||||||
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
|
|
||||||
</profile>
|
|
||||||
</component>
|
|
||||||
6
.idea/inspectionProfiles/profiles_settings.xml
generated
6
.idea/inspectionProfiles/profiles_settings.xml
generated
@@ -1,6 +0,0 @@
|
|||||||
<component name="InspectionProjectProfileManager">
|
|
||||||
<settings>
|
|
||||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
|
||||||
<version value="1.0" />
|
|
||||||
</settings>
|
|
||||||
</component>
|
|
||||||
6
.idea/sqldialects.xml
generated
Normal file
6
.idea/sqldialects.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="SqlDialectMappings">
|
||||||
|
<file url="file://$PROJECT_DIR$/doc/db_schemer_v1.1-pyqcrm-202503171158_clean.sql" dialect="MariaDB" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -6,13 +6,6 @@ ColumnLayout {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
spacing: Dimensions.l
|
spacing: Dimensions.l
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
employee_model.addedNewEmployee.connect(successful => {
|
|
||||||
if (successful)
|
|
||||||
contentStack.pop();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
ApplicantForm {
|
ApplicantForm {
|
||||||
id: applicantForm
|
id: applicantForm
|
||||||
|
|
||||||
@@ -36,7 +29,8 @@ ColumnLayout {
|
|||||||
text: qsTr("Speichern")
|
text: qsTr("Speichern")
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
employee_model.addApplicant(applicantForm.value);
|
applicantModel.createApplicant(applicantForm.value);
|
||||||
|
contentStack.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ ColumnLayout {
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.horizontalStretchFactor: 1
|
Layout.horizontalStretchFactor: 1
|
||||||
|
|
||||||
ApplicantPersonalData {
|
EmployeePersonalData {
|
||||||
id: personalData
|
id: personalData
|
||||||
|
|
||||||
implicitWidth: parent.width
|
implicitWidth: parent.width
|
||||||
@@ -61,14 +61,14 @@ ColumnLayout {
|
|||||||
Layout.alignment: Qt.AlignTop
|
Layout.alignment: Qt.AlignTop
|
||||||
implicitWidth: parent.width
|
implicitWidth: parent.width
|
||||||
|
|
||||||
ApplicantBankData {
|
EmployeeBankData {
|
||||||
id: bankAccount
|
id: bankAccount
|
||||||
|
|
||||||
}
|
}
|
||||||
ApplicantNationalInsurance {
|
EmployeeNationalInsurance {
|
||||||
id: nationalInsurance
|
id: nationalInsurance
|
||||||
}
|
}
|
||||||
ApplicantVarious {
|
EmployeeVarious {
|
||||||
id: applicantVarious
|
id: applicantVarious
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,19 +6,31 @@ import TeroStyle
|
|||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
readonly property int fieldM: 235
|
readonly property int fieldM: 235
|
||||||
readonly property int fieldS: 110
|
readonly property int fieldS: 110
|
||||||
readonly property bool valid: city.acceptableInput && email.acceptableInput && firstname.acceptableInput && lastname.acceptableInput && mobile.acceptableInput && phone.acceptableInput && postcode.acceptableInput && formofaddress.acceptableInput && title.acceptableInput
|
readonly property bool valid: emailAddress.acceptableInput && firstName.acceptableInput && houseNumber.acceptableInput && lastName.acceptableInput && mobileNumber.acceptableInput && phoneNumber.acceptableInput && salutation.acceptableInput&& street.acceptableInput && title.acceptableInput && zipCode.acceptableInput
|
||||||
readonly property var value: QtObject {
|
readonly property var value: QtObject {
|
||||||
readonly property string city: (city.editText ? city.editText : city.currentText) ?? ""
|
readonly property string emailAddress: emailAddress.text ?? ""
|
||||||
readonly property string email: email.text
|
readonly property string firstName: firstName.text ?? ""
|
||||||
readonly property string firstname: firstname.text
|
readonly property string houseNumber: houseNumber.text ?? ""
|
||||||
readonly property string formofaddress: formofaddress.currentText ?? ""
|
readonly property string lastName: lastName.text ?? ""
|
||||||
readonly property string houseno: houseno.text ?? ""
|
readonly property string mobileNumber: mobileNumber.text ?? ""
|
||||||
readonly property string lastname: lastname.text
|
readonly property string phoneNumber: phoneNumber.text ?? ""
|
||||||
readonly property string mobile: mobile.text
|
readonly property string salutation: salutation.text ?? ""
|
||||||
readonly property string phone: phone.text
|
readonly property string street: street.text ?? ""
|
||||||
readonly property string postcode: (postcode.editText ? postcode.editText : postcode.currentText) ?? ""
|
|
||||||
readonly property string street: (street.editText ? street.editText : street.currentText) ?? ""
|
|
||||||
readonly property string title: title.currentText
|
readonly property string title: title.currentText
|
||||||
|
readonly property int zipCode: zipCode.currentIndex
|
||||||
|
}
|
||||||
|
|
||||||
|
function setValue(value) {
|
||||||
|
title.currentIndex = value.title ?? 0;
|
||||||
|
firstName.text = value.firstName ?? "";
|
||||||
|
lastName.text = value.lastName ?? "";
|
||||||
|
street.text = value.street ?? "";
|
||||||
|
houseNumber.text = value.houseNumber ?? "";
|
||||||
|
zipCode.currentIndex = value.zipCode ?? -1;
|
||||||
|
phoneNumber.text = value.phoneNumber ?? "";
|
||||||
|
mobileNumber.text = value.mobileNumber ?? "";
|
||||||
|
emailAddress.text = value.emailAddress ?? "";
|
||||||
|
salutation.text = value.salutation ?? 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
spacing: Dimensions.l
|
spacing: Dimensions.l
|
||||||
@@ -48,13 +60,13 @@ ColumnLayout {
|
|||||||
onCurrentTextChanged: {
|
onCurrentTextChanged: {
|
||||||
switch (title.currentIndex) {
|
switch (title.currentIndex) {
|
||||||
case 1:
|
case 1:
|
||||||
formofaddress.text = "Sehr geehrter Herr ";
|
salutation.text = "Sehr geehrter Herr ";
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
formofaddress.text = "Sehr geehrte Frau ";
|
salutation.text = "Sehr geehrte Frau ";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
formofaddress.text = "Guten Tag ";
|
salutation.text = "Guten Tag ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -64,7 +76,7 @@ ColumnLayout {
|
|||||||
mandatory: true
|
mandatory: true
|
||||||
|
|
||||||
TextField {
|
TextField {
|
||||||
id: firstname
|
id: firstName
|
||||||
|
|
||||||
implicitWidth: fieldM
|
implicitWidth: fieldM
|
||||||
placeholderText: qsTr("Max")
|
placeholderText: qsTr("Max")
|
||||||
@@ -78,7 +90,7 @@ ColumnLayout {
|
|||||||
mandatory: true
|
mandatory: true
|
||||||
|
|
||||||
TextField {
|
TextField {
|
||||||
id: lastname
|
id: lastName
|
||||||
|
|
||||||
implicitWidth: fieldM
|
implicitWidth: fieldM
|
||||||
placeholderText: qsTr("Mustermann")
|
placeholderText: qsTr("Mustermann")
|
||||||
@@ -92,39 +104,30 @@ ColumnLayout {
|
|||||||
spacing: Dimensions.m
|
spacing: Dimensions.m
|
||||||
|
|
||||||
Field {
|
Field {
|
||||||
id: street
|
|
||||||
|
|
||||||
label: qsTr("Straße")
|
label: qsTr("Straße")
|
||||||
mandatory: true
|
|
||||||
|
|
||||||
TextField {
|
TextField {
|
||||||
|
id: street
|
||||||
|
|
||||||
implicitWidth: fieldM
|
implicitWidth: fieldM
|
||||||
placeholderText: qsTr("Musterstraße")
|
placeholderText: qsTr("Musterstraße")
|
||||||
|
|
||||||
validator: NotEmptyValidator {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Field {
|
Field {
|
||||||
id: houseno
|
|
||||||
mandatory: true
|
|
||||||
|
|
||||||
label: qsTr("Hausnummer")
|
label: qsTr("Hausnummer")
|
||||||
|
|
||||||
TextField {
|
TextField {
|
||||||
|
id: houseNumber
|
||||||
|
|
||||||
implicitWidth: fieldS
|
implicitWidth: fieldS
|
||||||
placeholderText: qsTr("1a")
|
placeholderText: qsTr("1a")
|
||||||
|
|
||||||
validator: NotEmptyValidator {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Field {
|
Field {
|
||||||
label: qsTr("PLZ")
|
label: qsTr("PLZ")
|
||||||
mandatory: true
|
|
||||||
|
|
||||||
ComboBox {
|
ComboBox {
|
||||||
id: postcode
|
id: zipCode
|
||||||
|
|
||||||
currentIndex: -1
|
currentIndex: -1
|
||||||
editable: true
|
editable: true
|
||||||
@@ -133,14 +136,11 @@ ColumnLayout {
|
|||||||
textRole: "display"
|
textRole: "display"
|
||||||
|
|
||||||
onActivated: currentValue
|
onActivated: currentValue
|
||||||
onCurrentIndexChanged: city.currentIndex = postcode.currentIndex
|
onCurrentIndexChanged: city.currentIndex = zipCode.currentIndex
|
||||||
|
|
||||||
validator: NotEmptyValidator {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Field {
|
Field {
|
||||||
label: qsTr("Ort")
|
label: qsTr("Ort")
|
||||||
mandatory: true
|
|
||||||
|
|
||||||
ComboBox {
|
ComboBox {
|
||||||
id: city
|
id: city
|
||||||
@@ -150,9 +150,6 @@ ColumnLayout {
|
|||||||
implicitWidth: fieldM
|
implicitWidth: fieldM
|
||||||
model: address_model
|
model: address_model
|
||||||
textRole: "city"
|
textRole: "city"
|
||||||
|
|
||||||
validator: NotEmptyValidator {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -173,7 +170,7 @@ ColumnLayout {
|
|||||||
label: qsTr("Telefonnummer")
|
label: qsTr("Telefonnummer")
|
||||||
|
|
||||||
TextField {
|
TextField {
|
||||||
id: phone
|
id: phoneNumber
|
||||||
|
|
||||||
implicitWidth: fieldM
|
implicitWidth: fieldM
|
||||||
placeholderText: "+49 1234 567890"
|
placeholderText: "+49 1234 567890"
|
||||||
@@ -186,7 +183,7 @@ ColumnLayout {
|
|||||||
label: qsTr("Mobil")
|
label: qsTr("Mobil")
|
||||||
|
|
||||||
TextField {
|
TextField {
|
||||||
id: mobile
|
id: mobileNumber
|
||||||
|
|
||||||
implicitWidth: fieldM
|
implicitWidth: fieldM
|
||||||
placeholderText: "+49 123 4567891011"
|
placeholderText: "+49 123 4567891011"
|
||||||
@@ -199,7 +196,7 @@ ColumnLayout {
|
|||||||
label: qsTr("E-Mail Adresse")
|
label: qsTr("E-Mail Adresse")
|
||||||
|
|
||||||
TextField {
|
TextField {
|
||||||
id: email
|
id: emailAddress
|
||||||
|
|
||||||
implicitWidth: fieldM
|
implicitWidth: fieldM
|
||||||
placeholderText: "tero@example.org"
|
placeholderText: "tero@example.org"
|
||||||
@@ -212,7 +209,7 @@ ColumnLayout {
|
|||||||
label: qsTr("Briefanrede")
|
label: qsTr("Briefanrede")
|
||||||
|
|
||||||
TextField {
|
TextField {
|
||||||
id: formofaddress
|
id: salutation
|
||||||
|
|
||||||
implicitWidth: fieldM
|
implicitWidth: fieldM
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +1,34 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
import TeroStyle
|
||||||
|
|
||||||
Item
|
ColumnLayout {
|
||||||
{
|
property int row: -1
|
||||||
property int selectedEmployee: -1
|
|
||||||
id: emDet
|
|
||||||
ColumnLayout
|
|
||||||
{
|
|
||||||
Label
|
|
||||||
{
|
|
||||||
text: qsTr("Ausgewählter Mitarbeiter " + selectedEmployee)
|
|
||||||
}
|
|
||||||
|
|
||||||
Button
|
anchors.fill: parent
|
||||||
{
|
spacing: Dimensions.l
|
||||||
text: qsTr("Mitarbeiter zeigen")
|
|
||||||
onClicked: contentStack.pop()
|
onRowChanged: {
|
||||||
|
if (row !== -1) {
|
||||||
|
applicantForm.setValue(applicantModel.applicant(row))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted:
|
ApplicantForm {
|
||||||
{
|
id: applicantForm
|
||||||
employee_model.onRowClicked(selectedEmployee)
|
|
||||||
|
Layout.alignment: Qt.AlignTop
|
||||||
|
Layout.fillHeight: true
|
||||||
|
Layout.verticalStretchFactor: 1
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
spacing: Dimensions.l
|
||||||
|
|
||||||
|
Button {
|
||||||
|
text: qsTr("Als Mitarbeiter:in Einstellen")
|
||||||
|
icon.source: "qrc:/images/InboxArrowDown.svg"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ ColumnLayout {
|
|||||||
spacing: Dimensions.l
|
spacing: Dimensions.l
|
||||||
|
|
||||||
SearchBar {
|
SearchBar {
|
||||||
|
onSubmitted: (query) => {
|
||||||
|
applicantModel.searchQuery = query
|
||||||
|
}
|
||||||
}
|
}
|
||||||
QuickFilter {
|
QuickFilter {
|
||||||
model: ListModel {
|
model: ListModel {
|
||||||
@@ -92,7 +95,7 @@ ColumnLayout {
|
|||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
columnSpacing: 2
|
columnSpacing: 2
|
||||||
model: employee_model
|
model: applicantModel
|
||||||
resizableColumns: true
|
resizableColumns: true
|
||||||
rowSpacing: 2
|
rowSpacing: 2
|
||||||
selectionBehavior: TableView.SelectRows
|
selectionBehavior: TableView.SelectRows
|
||||||
@@ -124,9 +127,7 @@ ColumnLayout {
|
|||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
contentStack.push("EmployeeDetails.qml", {
|
contentStack.push("EmployeeDetails.qml", { row });
|
||||||
selectedEmployee: row
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
onEntered: {
|
onEntered: {
|
||||||
employeesTable.selectionModel.select(employeesTable.model.index(row, 0), ItemSelectionModel.SelectCurrent | ItemSelectionModel.Rows);
|
employeesTable.selectionModel.select(employeesTable.model.index(row, 0), ItemSelectionModel.SelectCurrent | ItemSelectionModel.Rows);
|
||||||
|
|||||||
@@ -4,11 +4,23 @@ import QtQuick.Layouts
|
|||||||
|
|
||||||
|
|
||||||
TextField {
|
TextField {
|
||||||
|
id: field
|
||||||
|
|
||||||
|
signal submitted(query: string)
|
||||||
|
|
||||||
Layout.preferredWidth: 300
|
Layout.preferredWidth: 300
|
||||||
placeholderText: qsTr("Suche")
|
placeholderText: qsTr("Suche")
|
||||||
|
|
||||||
|
Keys.onReturnPressed: {
|
||||||
|
field.submitted(field.text);
|
||||||
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
icon.source: "qrc:/images/MagnifyingGlass.svg"
|
icon.source: "qrc:/images/MagnifyingGlass.svg"
|
||||||
isFieldButton: true
|
isFieldButton: true
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
field.submitted(field.text)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
14
docker-compose.yml
Normal file
14
docker-compose.yml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
services:
|
||||||
|
mariadb:
|
||||||
|
image: mariadb:latest
|
||||||
|
volumes:
|
||||||
|
- mariadb:/var/lib/mysql
|
||||||
|
ports:
|
||||||
|
- 127.0.0.1:8000:3306
|
||||||
|
environment:
|
||||||
|
MARIADB_ROOT_PASSWORD: pyqcrm
|
||||||
|
MARIADB_USER: pyqcrm
|
||||||
|
MARIADB_PASSWORD: pyqcrm
|
||||||
|
MARIADB_DATABASE: pyqcrm
|
||||||
|
volumes:
|
||||||
|
mariadb:
|
||||||
4
images/InboxArrowDown.svg
Normal file
4
images/InboxArrowDown.svg
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<svg fill="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" data-slot="icon">
|
||||||
|
<path clip-rule="evenodd" fill-rule="evenodd" d="M5.478 5.559A1.5 1.5 0 0 1 6.912 4.5H9A.75.75 0 0 0 9 3H6.912a3 3 0 0 0-2.868 2.118l-2.411 7.838a3 3 0 0 0-.133.882V18a3 3 0 0 0 3 3h15a3 3 0 0 0 3-3v-4.162c0-.299-.045-.596-.133-.882l-2.412-7.838A3 3 0 0 0 17.088 3H15a.75.75 0 0 0 0 1.5h2.088a1.5 1.5 0 0 1 1.434 1.059l2.213 7.191H17.89a3 3 0 0 0-2.684 1.658l-.256.513a1.5 1.5 0 0 1-1.342.829h-3.218a1.5 1.5 0 0 1-1.342-.83l-.256-.512a3 3 0 0 0-2.684-1.658H3.265l2.213-7.191Z"></path>
|
||||||
|
<path clip-rule="evenodd" fill-rule="evenodd" d="M12 2.25a.75.75 0 0 1 .75.75v6.44l1.72-1.72a.75.75 0 1 1 1.06 1.06l-3 3a.75.75 0 0 1-1.06 0l-3-3a.75.75 0 0 1 1.06-1.06l1.72 1.72V3a.75.75 0 0 1 .75-.75Z"></path>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 824 B |
19
lib/Config.py
Normal file
19
lib/Config.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
from typing import TypedDict
|
||||||
|
|
||||||
|
|
||||||
|
class EncryptionConfig(TypedDict):
|
||||||
|
ENCRYPTION_KEY_VALID: str
|
||||||
|
ENCRYPTION_KEY: str
|
||||||
|
|
||||||
|
|
||||||
|
class DatabaseConfig(TypedDict):
|
||||||
|
DB_HOST: str
|
||||||
|
DB_USER: str
|
||||||
|
DB_PASS: str
|
||||||
|
DB_NAME: str
|
||||||
|
DB_PORT: str
|
||||||
|
|
||||||
|
|
||||||
|
class Config(TypedDict):
|
||||||
|
database: DatabaseConfig
|
||||||
|
pyqcrm: EncryptionConfig
|
||||||
@@ -1,27 +1,28 @@
|
|||||||
# This Python file uses the following encoding: utf-8
|
# This Python file uses the following encoding: utf-8
|
||||||
import toml
|
|
||||||
from platformdirs import user_config_dir
|
|
||||||
from pathlib import Path
|
|
||||||
from PySide6.QtCore import QObject, Slot, Signal
|
|
||||||
from .Vermasseln import Vermasseln
|
|
||||||
import shutil
|
|
||||||
from urllib.parse import urlparse
|
|
||||||
from .DB.DbManager import DbManager
|
|
||||||
import os
|
import os
|
||||||
from Crypto.Random import get_random_bytes
|
|
||||||
from base64 import b64encode
|
from base64 import b64encode
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import Optional
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
|
import toml
|
||||||
|
from Crypto.Random import get_random_bytes
|
||||||
|
from PySide6.QtCore import QObject, Slot, Signal
|
||||||
|
from peewee import OperationalError
|
||||||
|
from platformdirs import user_config_dir
|
||||||
|
|
||||||
|
from .Config import Config, DatabaseConfig
|
||||||
from .DB.UserManager import UserManager
|
from .DB.UserManager import UserManager
|
||||||
from .PyqcrmFlags import PyqcrmFlags
|
from .PyqcrmFlags import PyqcrmFlags
|
||||||
|
from .Vermasseln import Vermasseln
|
||||||
|
from .domain.BaseModel import init_database_from_config
|
||||||
|
|
||||||
|
|
||||||
class ConfigLoader(QObject):
|
class ConfigLoader(QObject):
|
||||||
__config = None
|
__config: Optional[Config] = None
|
||||||
__version = "0.1-alpha"
|
__version = "0.1-alpha"
|
||||||
__check_enc_key = True
|
__check_enc_key = True
|
||||||
|
|
||||||
|
|
||||||
dbConnectionError = Signal(str, bool)
|
dbConnectionError = Signal(str, bool)
|
||||||
adminUserError = Signal(str, bool)
|
adminUserError = Signal(str, bool)
|
||||||
adminNotAsvailable = Signal()
|
adminNotAsvailable = Signal()
|
||||||
@@ -31,7 +32,6 @@ class ConfigLoader(QObject):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
# print(f"In {__file__} file, __init__()")
|
|
||||||
self.config_dir = user_config_dir() + '/pyqcrm'
|
self.config_dir = user_config_dir() + '/pyqcrm'
|
||||||
config_dir = Path(self.config_dir)
|
config_dir = Path(self.config_dir)
|
||||||
if config_dir.exists():
|
if config_dir.exists():
|
||||||
@@ -41,13 +41,11 @@ class ConfigLoader(QObject):
|
|||||||
else:
|
else:
|
||||||
config_dir.mkdir(0o750, True, True)
|
config_dir.mkdir(0o750, True, True)
|
||||||
|
|
||||||
|
@Slot(dict, result=bool)
|
||||||
@Slot(dict, result = bool)
|
def setConfig(self, app_config: Config):
|
||||||
def setConfig(self, app_config):
|
|
||||||
# print(f"In {__file__} file, setConfig()")
|
|
||||||
if not self.__config:
|
if not self.__config:
|
||||||
base_conf = self.__initializeConfig()
|
base_conf = self.__initializeConfig()
|
||||||
conf = self.__checkDbConnection(app_config)
|
conf = self._is_db_connectable(app_config['database'])
|
||||||
app_config = toml.dumps(app_config)
|
app_config = toml.dumps(app_config)
|
||||||
if conf:
|
if conf:
|
||||||
app_config = base_conf + app_config
|
app_config = base_conf + app_config
|
||||||
@@ -58,52 +56,48 @@ class ConfigLoader(QObject):
|
|||||||
self.configurationReady.emit()
|
self.configurationReady.emit()
|
||||||
|
|
||||||
def __initializeConfig(self):
|
def __initializeConfig(self):
|
||||||
# print(f"In {__file__} file, __initializeConfig()")
|
|
||||||
self.__encrypt_key = b64encode(get_random_bytes(32)).decode("utf-8")
|
self.__encrypt_key = b64encode(get_random_bytes(32)).decode("utf-8")
|
||||||
conf = f"[pyqcrm]\nVERSION = \"{self.__version}\"\n"
|
conf = f"[pyqcrm]\nVERSION = \"{self.__version}\"\n"
|
||||||
conf = conf + f"ENCRYPTION_KEY_VALID = \"No\"\n"
|
conf = conf + f"ENCRYPTION_KEY_VALID = \"No\"\n"
|
||||||
conf = conf + f"ENCRYPTION_KEY = \"{self.__encrypt_key}\"\n\n"
|
conf = conf + f"ENCRYPTION_KEY = \"{self.__encrypt_key}\"\n\n"
|
||||||
return conf
|
return conf
|
||||||
|
|
||||||
def __checkDbConnection(self, db_config):
|
def _is_db_connectable(self, config: DatabaseConfig):
|
||||||
# print(f"In {__file__} file, __checkDbConnection()")
|
try:
|
||||||
con = DbManager(db_config['database']).getConnection()
|
init_database_from_config(config)
|
||||||
if con:
|
|
||||||
self.dbConnectionError.emit("Connection OK", True)
|
self.dbConnectionError.emit("Connection OK", True)
|
||||||
return True
|
return True
|
||||||
else:
|
except OperationalError as e:
|
||||||
self.dbConnectionError.emit("Connection fehlgeschlagen", False)
|
self.dbConnectionError.emit("Connection fehlgeschlagen", False)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def __saveConfig(self):
|
def __saveConfig(self):
|
||||||
# print(f"In {__file__} file, saveConfig()")
|
# print(f"In {__file__} file, saveConfig()")
|
||||||
try:
|
try:
|
||||||
with open (self.config_dir + '/pyqcrm.toml', 'w') as f:
|
with open(self.config_dir + '/pyqcrm.toml', 'w') as f:
|
||||||
# print(self.__config)
|
# print(self.__config)
|
||||||
config = Vermasseln().oscarVermasseln(toml.dumps(self.__config))
|
config = Vermasseln().oscarVermasseln(toml.dumps(self.__config))
|
||||||
f.write(config)
|
f.write(config)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print("Konnte die Konfiguration nicht speichern.")
|
print("Konnte die Konfiguration nicht speichern.")
|
||||||
|
|
||||||
|
|
||||||
def __checkAdminUser(self):
|
def __checkAdminUser(self):
|
||||||
# print(f"In {__file__} file, __checkAdminUser()")
|
# print(f"In {__file__} file, __checkAdminUser()")
|
||||||
result = UserManager().checkAdmin()
|
result = UserManager().checkAdmin()
|
||||||
if not result:
|
if not result:
|
||||||
#if not result[0][0] == 1:
|
# if not result[0][0] == 1:
|
||||||
self.adminUserError.emit("Kein Admin vorhanden", False)
|
self.adminUserError.emit("Kein Admin vorhanden", False)
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
self.adminUserError.emit("Admin vorhanden", True)
|
self.adminUserError.emit("Admin vorhanden", True)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@Slot(dict, result= bool)
|
@Slot(dict, result=bool)
|
||||||
def addAdminUser(self, user_config):
|
def addAdminUser(self, user_config):
|
||||||
# print(f"In {__file__} file, addAdminUser()")
|
# print(f"In {__file__} file, addAdminUser()")
|
||||||
admin = UserManager(user_config["user"], PyqcrmFlags.ADMIN).createUser()
|
admin = UserManager(user_config["user"], PyqcrmFlags.ADMIN).createUser()
|
||||||
if not admin:
|
if not admin:
|
||||||
#self.adminNotAvailable.emit()
|
# self.adminNotAvailable.emit()
|
||||||
self.adminUserError.emit("Benutzername nich verfügbar", False)
|
self.adminUserError.emit("Benutzername nich verfügbar", False)
|
||||||
else:
|
else:
|
||||||
self.__config['pyqcrm']['ENCRYPTION_KEY_VALID'] = 'Yes'
|
self.__config['pyqcrm']['ENCRYPTION_KEY_VALID'] = 'Yes'
|
||||||
@@ -111,7 +105,6 @@ class ConfigLoader(QObject):
|
|||||||
self.backupEncryptionKey.emit()
|
self.backupEncryptionKey.emit()
|
||||||
return admin
|
return admin
|
||||||
|
|
||||||
|
|
||||||
@Slot(str, str)
|
@Slot(str, str)
|
||||||
def __saveData(self, recovery_file, recovery_password, data):
|
def __saveData(self, recovery_file, recovery_password, data):
|
||||||
# print(f"In {__file__} file, __saveData()")
|
# print(f"In {__file__} file, __saveData()")
|
||||||
@@ -121,7 +114,7 @@ class ConfigLoader(QObject):
|
|||||||
rf = Vermasseln().oscarVermasseln(rf, local)
|
rf = Vermasseln().oscarVermasseln(rf, local)
|
||||||
rec_file = urlparse(recovery_file)
|
rec_file = urlparse(recovery_file)
|
||||||
if os.name == "nt":
|
if os.name == "nt":
|
||||||
rec_file = rec_file [1:]
|
rec_file = rec_file[1:]
|
||||||
else:
|
else:
|
||||||
rec_file = rec_file.path + ".pyqrec"
|
rec_file = rec_file.path + ".pyqrec"
|
||||||
try:
|
try:
|
||||||
@@ -136,7 +129,7 @@ class ConfigLoader(QObject):
|
|||||||
rec_file = urlparse(recovery_file)
|
rec_file = urlparse(recovery_file)
|
||||||
rec_file = rec_file.path
|
rec_file = rec_file.path
|
||||||
if os.name == "nt":
|
if os.name == "nt":
|
||||||
rec_file = rec_file [1:]
|
rec_file = rec_file[1:]
|
||||||
try:
|
try:
|
||||||
ek = self.__parseImport(rec_file, recovery_password)
|
ek = self.__parseImport(rec_file, recovery_password)
|
||||||
|
|
||||||
@@ -165,7 +158,6 @@ class ConfigLoader(QObject):
|
|||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def __invalidateEncryptionKey(self):
|
def __invalidateEncryptionKey(self):
|
||||||
# print(f"In {__file__} file, __invalidateEncryptionKey()")
|
# print(f"In {__file__} file, __invalidateEncryptionKey()")
|
||||||
self.__config['pyqcrm']['ENCRYPTION_KEY_VALID'] = 'No'
|
self.__config['pyqcrm']['ENCRYPTION_KEY_VALID'] = 'No'
|
||||||
@@ -200,15 +192,9 @@ class ConfigLoader(QObject):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(str(e))
|
print(str(e))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def __configLoad(self):
|
def __configLoad(self):
|
||||||
# print(f"In {__file__} file, __configLoad()")
|
|
||||||
try:
|
try:
|
||||||
with open (self.config_dir + '/pyqcrm.toml', 'r') as f:
|
with open(self.config_dir + '/pyqcrm.toml', 'r') as f:
|
||||||
config = f.read()
|
config = f.read()
|
||||||
self.__config = toml.loads(Vermasseln().entschluesseln(config))
|
self.__config = toml.loads(Vermasseln().entschluesseln(config))
|
||||||
self.configurationReady.emit()
|
self.configurationReady.emit()
|
||||||
@@ -216,17 +202,11 @@ class ConfigLoader(QObject):
|
|||||||
print("Konnte die Konfiguration nicht laden.")
|
print("Konnte die Konfiguration nicht laden.")
|
||||||
except TypeError:
|
except TypeError:
|
||||||
print(f"Invalid Configuration: {__file__}")
|
print(f"Invalid Configuration: {__file__}")
|
||||||
except Exception as e:
|
|
||||||
print(str(e))
|
|
||||||
|
|
||||||
|
def get_config(self) -> Optional[Config]:
|
||||||
def getConfig(self):
|
|
||||||
# print(f"In {__file__} file, getConfig()")
|
|
||||||
# print(self.__config)
|
|
||||||
return self.__config
|
return self.__config
|
||||||
|
|
||||||
def __setRecoveryPassword(self, key, salt = None):
|
def __setRecoveryPassword(self, key, salt=None):
|
||||||
# print(f"In {__file__} file, __setRecoveryPassword()")
|
|
||||||
key = Vermasseln.userPasswordHash(key, salt)
|
key = Vermasseln.userPasswordHash(key, salt)
|
||||||
return key.split("$")
|
return key.split("$")
|
||||||
|
|
||||||
@@ -239,29 +219,28 @@ class ConfigLoader(QObject):
|
|||||||
|
|
||||||
@Slot(str, str)
|
@Slot(str, str)
|
||||||
def backupConfig(self, filename, password):
|
def backupConfig(self, filename, password):
|
||||||
conf_file = toml.dumps(self.getConfig())
|
conf_file = toml.dumps(self.get_config())
|
||||||
self.__saveData(filename, password, conf_file)
|
self.__saveData(filename, password, conf_file)
|
||||||
|
|
||||||
|
|
||||||
@Slot(dict)
|
@Slot(dict)
|
||||||
def saveDbConf(self, db = None):
|
def saveDbConf(self, db=None):
|
||||||
self.__config.update(db)
|
self.__config.update(db)
|
||||||
self.__saveConfig()
|
self.__saveConfig()
|
||||||
|
|
||||||
@Slot(result = dict)
|
@Slot(result=dict)
|
||||||
def getDbConf(self):
|
def getDbConf(self):
|
||||||
try:
|
try:
|
||||||
return self.__config['database']
|
return self.__config['database'] if self.__config is not None else None
|
||||||
except KeyError as ex:
|
except KeyError as ex:
|
||||||
print(f"Missing database configuration: {ex}")
|
print(f"Missing database configuration: {ex}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@Slot(dict)
|
@Slot(dict)
|
||||||
def saveCompanyInfo(self, company = None):
|
def saveCompanyInfo(self, company=None):
|
||||||
self.__config.update(company)
|
self.__config.update(company)
|
||||||
self.__saveConfig()
|
self.__saveConfig()
|
||||||
|
|
||||||
@Slot(result = dict)
|
@Slot(result=dict)
|
||||||
def getCompanyInfo(self):
|
def getCompanyInfo(self):
|
||||||
try:
|
try:
|
||||||
return self.__config['company']
|
return self.__config['company']
|
||||||
@@ -270,11 +249,11 @@ class ConfigLoader(QObject):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
@Slot(dict)
|
@Slot(dict)
|
||||||
def saveMiscConf(self, misc_conf = None):
|
def saveMiscConf(self, misc_conf=None):
|
||||||
self.__config.update(misc_conf)
|
self.__config.update(misc_conf)
|
||||||
self.__saveConfig()
|
self.__saveConfig()
|
||||||
|
|
||||||
@Slot(result = bool)
|
@Slot(result=bool)
|
||||||
def systray(self):
|
def systray(self):
|
||||||
try:
|
try:
|
||||||
return self.__config['misc']['SYSTRAY']
|
return self.__config['misc']['SYSTRAY']
|
||||||
@@ -282,9 +261,7 @@ class ConfigLoader(QObject):
|
|||||||
print(f"Missing configuration: {ex}")
|
print(f"Missing configuration: {ex}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
@Slot(str, str)
|
@Slot(str, str)
|
||||||
def backupEncryptkey(self, filename, password):
|
def backupEncryptkey(self, filename, password):
|
||||||
encrypt_key = self.__config['pyqcrm']['ENCRYPTION_KEY']
|
encrypt_key = self.__config['pyqcrm']['ENCRYPTION_KEY']
|
||||||
self.__saveData(filename, password, encrypt_key)
|
self.__saveData(filename, password, encrypt_key)
|
||||||
|
|
||||||
|
|||||||
@@ -1,27 +1,26 @@
|
|||||||
from .DbManager import DbManager
|
|
||||||
import mariadb
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
import mariadb
|
||||||
|
|
||||||
|
from lib.domain.BaseModel import database
|
||||||
|
|
||||||
|
|
||||||
class AddressDAO:
|
class AddressDAO:
|
||||||
__cur = None
|
__cur = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
#print(f"*** File: {__file__}, init()")
|
self.__con = database.connection()
|
||||||
self.__con = DbManager().getConnection()
|
|
||||||
|
|
||||||
if self.__con:
|
if self.__con:
|
||||||
self.__cur = self.__con.cursor()
|
self.__cur = self.__con.cursor()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def __importPlz(self):
|
def __importPlz(self):
|
||||||
with open("pfad zur datei", "r") as plz:
|
with open("pfad zur datei", "r") as plz:
|
||||||
postcodes = json.load(plz)
|
postcodes = json.load(plz)
|
||||||
irgendwas = ""
|
irgendwas = ""
|
||||||
try:
|
try:
|
||||||
for i in postcodes:
|
for i in postcodes:
|
||||||
test =i["plz_name"].split(",")
|
test = i["plz_name"].split(",")
|
||||||
for town in test:
|
for town in test:
|
||||||
if "u.a" in town:
|
if "u.a" in town:
|
||||||
town = town[:-4]
|
town = town[:-4]
|
||||||
@@ -29,12 +28,12 @@ class AddressDAO:
|
|||||||
if town:
|
if town:
|
||||||
print(f"PROCESSING {i['name']} {town}")
|
print(f"PROCESSING {i['name']} {town}")
|
||||||
self.__cur.callproc("addZipCodes", (i["name"], town, irgendwas,))
|
self.__cur.callproc("addZipCodes", (i["name"], town, irgendwas,))
|
||||||
#self.__cur.callproc("addZipCodes", ("56271", "Kleinmaischeid", irgendwas,))
|
# self.__cur.callproc("addZipCodes", ("56271", "Kleinmaischeid", irgendwas,))
|
||||||
except mariadb.OperationalError as e:
|
except mariadb.OperationalError as e:
|
||||||
print(f"Database Error: {e}")
|
print(f"Database Error: {e}")
|
||||||
finally:
|
finally:
|
||||||
self.__con.commit()
|
self.__con.commit()
|
||||||
print("FINISHED")#
|
print("FINISHED") #
|
||||||
|
|
||||||
def __importCountry(self):
|
def __importCountry(self):
|
||||||
with open("pfad zur datei", "r") as country:
|
with open("pfad zur datei", "r") as country:
|
||||||
@@ -55,18 +54,17 @@ class AddressDAO:
|
|||||||
|
|
||||||
print(i[4], i[3], i[2], i[8], i[7])
|
print(i[4], i[3], i[2], i[8], i[7])
|
||||||
|
|
||||||
self.__cur.execute("INSERT INTO country (country, countryshort, nationality, iso2, iso3) VALUES (%s, %s, %s, %s, %s)", (i[4], i[3], i[2], i[8], i[7]))
|
self.__cur.execute(
|
||||||
|
"INSERT INTO country (country, countryshort, nationality, iso2, iso3) VALUES (%s, %s, %s, %s, %s)",
|
||||||
|
(i[4], i[3], i[2], i[8], i[7]))
|
||||||
old = i[4]
|
old = i[4]
|
||||||
except mariadb.OperationalError as e:
|
except mariadb.OperationalError as e:
|
||||||
print(f"Database Error: {e}")
|
print(f"Database Error: {e}")
|
||||||
finally:
|
finally:
|
||||||
self.__con.commit()
|
self.__con.commit()
|
||||||
print("FINISHED")#
|
print("FINISHED") #
|
||||||
|
|
||||||
|
def getAddressData(self, all=True, zipcode=None):
|
||||||
|
|
||||||
|
|
||||||
def getAddressData(self, all = True, zipcode = None):
|
|
||||||
try:
|
try:
|
||||||
if self.__cur:
|
if self.__cur:
|
||||||
self.__cur.callproc("getAddress", (all, zipcode,))
|
self.__cur.callproc("getAddress", (all, zipcode,))
|
||||||
@@ -76,5 +74,3 @@ class AddressDAO:
|
|||||||
return None
|
return None
|
||||||
except mariadb.Error as e:
|
except mariadb.Error as e:
|
||||||
print(str(e))
|
print(str(e))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,18 +2,19 @@ from PySide6.QtCore import QAbstractListModel, Qt, Slot, QModelIndex
|
|||||||
from .AddressDAO import AddressDAO
|
from .AddressDAO import AddressDAO
|
||||||
from ..PyqcrmDataRoles import PyqcrmDataRoles
|
from ..PyqcrmDataRoles import PyqcrmDataRoles
|
||||||
|
|
||||||
|
|
||||||
class AddressModel(QAbstractListModel):
|
class AddressModel(QAbstractListModel):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.__address_data = AddressDAO().getAddressData()
|
self.__address_data = AddressDAO().getAddressData()
|
||||||
|
|
||||||
def rowCount(self, parent = QModelIndex()):
|
def rowCount(self, parent=QModelIndex()):
|
||||||
return len(self.__address_data)
|
return len(self.__address_data)
|
||||||
|
|
||||||
def data(self, index, role = Qt.DisplayRole):
|
def data(self, index, role=Qt.ItemDataRole.DisplayRole):
|
||||||
row = index.row()
|
row = index.row()
|
||||||
if role == Qt.DisplayRole:
|
if role == Qt.ItemDataRole.DisplayRole:
|
||||||
data = self.__address_data[row][2]
|
data = self.__address_data[row][2]
|
||||||
return data
|
return data
|
||||||
elif role == PyqcrmDataRoles.CITY_ROLE:
|
elif role == PyqcrmDataRoles.CITY_ROLE:
|
||||||
@@ -23,20 +24,11 @@ class AddressModel(QAbstractListModel):
|
|||||||
|
|
||||||
def roleNames(self):
|
def roleNames(self):
|
||||||
return {
|
return {
|
||||||
Qt.DisplayRole: b"display",
|
Qt.ItemDataRole.DisplayRole: b"display",
|
||||||
PyqcrmDataRoles.CITY_ROLE: b"city",
|
PyqcrmDataRoles.CITY_ROLE: b"city",
|
||||||
}
|
}
|
||||||
|
|
||||||
def setData(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
@Slot(bool, str)
|
@Slot(bool, str)
|
||||||
def getAddresses(self, all, zipcode):
|
def getAddresses(self, all, zipcode):
|
||||||
data = AddressDAO().getAddressData(all, zipcode)
|
data = AddressDAO().getAddressData(all, zipcode)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
91
lib/DB/ApplicantModel.py
Normal file
91
lib/DB/ApplicantModel.py
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
import uuid
|
||||||
|
from typing import List, Callable, Any
|
||||||
|
|
||||||
|
from PySide6.QtCore import QModelIndex, Qt, QAbstractTableModel, Slot, Property, Signal
|
||||||
|
from PySide6.QtQml import QJSValue
|
||||||
|
from peewee import Select
|
||||||
|
|
||||||
|
from lib.domain.Applicant import Applicant
|
||||||
|
|
||||||
|
COLUMNS: list[Callable[[Applicant], Any]] = [
|
||||||
|
lambda applicant: applicant.first_name,
|
||||||
|
lambda applicant: applicant.last_name,
|
||||||
|
lambda applicant: applicant.zip_code.zip_code or None,
|
||||||
|
lambda applicant: applicant.zip_code.town.town if applicant.zip_code.id is not None else None
|
||||||
|
]
|
||||||
|
|
||||||
|
COLUMN_NAMES = ["Vorname", "Nachname", "PLZ", "Ort"]
|
||||||
|
|
||||||
|
|
||||||
|
class ApplicantModel(QAbstractTableModel):
|
||||||
|
_applicants: Select
|
||||||
|
_search_query: str = ""
|
||||||
|
search_query_changed = Signal(str)
|
||||||
|
|
||||||
|
def __init__(self) -> None:
|
||||||
|
super().__init__()
|
||||||
|
self._query_applicants()
|
||||||
|
|
||||||
|
def rowCount(self, /, parent=...):
|
||||||
|
return len(self._applicants)
|
||||||
|
|
||||||
|
def columnCount(self, /, parent=...):
|
||||||
|
return len(COLUMNS)
|
||||||
|
|
||||||
|
def data(self, index: QModelIndex, role: int = Qt.ItemDataRole.DisplayRole):
|
||||||
|
if role == Qt.ItemDataRole.DisplayRole:
|
||||||
|
applicant = self._applicants[index.row()]
|
||||||
|
return COLUMNS[index.column()](applicant)
|
||||||
|
return None
|
||||||
|
|
||||||
|
@Property(str, notify=search_query_changed)
|
||||||
|
def searchQuery(self):
|
||||||
|
return self._search_query
|
||||||
|
|
||||||
|
@searchQuery.setter
|
||||||
|
def searchQuery(self, value: str):
|
||||||
|
self._search_query = value
|
||||||
|
self._query_applicants()
|
||||||
|
|
||||||
|
@Slot(int, result=dict)
|
||||||
|
def applicant(self, row) -> dict:
|
||||||
|
applicant = Applicant.get_by_id(self._applicants[row].id)
|
||||||
|
return {
|
||||||
|
'title': applicant.title,
|
||||||
|
"firstName": applicant.first_name,
|
||||||
|
"lastName": applicant.last_name,
|
||||||
|
"street": applicant.street,
|
||||||
|
"houseNumber": applicant.house_number,
|
||||||
|
"zipCode": applicant.zip_code_id,
|
||||||
|
"phoneNumber": applicant.phone_number,
|
||||||
|
"mobileNumber": applicant.mobile_number,
|
||||||
|
"emailAddress": applicant.email_address,
|
||||||
|
"salutation": applicant.salutation
|
||||||
|
}
|
||||||
|
|
||||||
|
@Slot(QJSValue)
|
||||||
|
def createApplicant(self, values: QJSValue):
|
||||||
|
applicant = Applicant()
|
||||||
|
applicant.id = uuid.uuid4()
|
||||||
|
applicant.title = values.property("title").toInt()
|
||||||
|
applicant.first_name = values.property("firstName").toString()
|
||||||
|
applicant.last_name = values.property("lastName").toString()
|
||||||
|
applicant.street = values.property("street").toString() or None
|
||||||
|
applicant.house_number = values.property("houseNumber").toString() or None
|
||||||
|
if values.property("zipCode").toInt() != -1:
|
||||||
|
applicant.zip_code = values.property("zipCode").toInt()
|
||||||
|
applicant.phone_number = values.property("phoneNumber").toString() or None
|
||||||
|
applicant.mobile_number = values.property("mobileNumber").toString() or None
|
||||||
|
applicant.email_address = values.property("emailAddress").toString() or None
|
||||||
|
applicant.salutation = values.property("salutation").toString() or None
|
||||||
|
applicant.save(force_insert=True)
|
||||||
|
self._query_applicants()
|
||||||
|
|
||||||
|
def headerData(self, section: int, orientation: Qt.Orientation, role: int = Qt.ItemDataRole.DisplayRole):
|
||||||
|
if role == Qt.ItemDataRole.DisplayRole:
|
||||||
|
return COLUMN_NAMES[section]
|
||||||
|
return None
|
||||||
|
|
||||||
|
def _query_applicants(self):
|
||||||
|
self._applicants = Applicant.select_table_data(self._search_query)
|
||||||
|
self.layoutChanged.emit()
|
||||||
@@ -1,20 +1,20 @@
|
|||||||
from .DbManager import DbManager
|
from lib.domain.BaseModel import database
|
||||||
|
|
||||||
|
|
||||||
class BTypeDAO:
|
class BTypeDAO:
|
||||||
__cur = None
|
__cur = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
#print(f"*** File: {__file__}, init()")
|
self.__con = database.connection()
|
||||||
self.__con = DbManager().getConnection()
|
|
||||||
if self.__con:
|
if self.__con:
|
||||||
self.__cur = self.__con.cursor()
|
self.__cur = self.__con.cursor()
|
||||||
|
|
||||||
def getBType(self):
|
def getBType(self):
|
||||||
try:
|
try:
|
||||||
if self.__cur:
|
if self.__cur:
|
||||||
self.__cur.callproc("getBtype", (None, None, ))
|
self.__cur.callproc("getBtype", (None, None,))
|
||||||
data = self.__cur.fetchall()
|
data = self.__cur.fetchall()
|
||||||
return(data)
|
return data
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
except mariadb.Error as e:
|
except mariadb.Error as e:
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from .DbManager import DbManager
|
|
||||||
import json
|
import json
|
||||||
import mariadb
|
import mariadb
|
||||||
from PySide6.QtCore import QObject, Signal
|
from PySide6.QtCore import QObject, Signal
|
||||||
|
from lib.domain.BaseModel import database
|
||||||
|
|
||||||
|
|
||||||
class BusinessDAO(QObject):
|
class BusinessDAO(QObject):
|
||||||
@@ -12,11 +12,11 @@ class BusinessDAO(QObject):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.__con = DbManager().getConnection()
|
self.__con = database.connection()
|
||||||
if self.__con:
|
if self.__con:
|
||||||
self.__cur = self.__con.cursor()
|
self.__cur = self.__con.cursor()
|
||||||
|
|
||||||
def getBusiness(self, enc_key, criterion = "Alle"):
|
def getBusiness(self, enc_key, criterion="Alle"):
|
||||||
try:
|
try:
|
||||||
if self.__cur:
|
if self.__cur:
|
||||||
self.__cur.callproc("getCustomerView", (enc_key, criterion,))
|
self.__cur.callproc("getCustomerView", (enc_key, criterion,))
|
||||||
@@ -27,14 +27,14 @@ class BusinessDAO(QObject):
|
|||||||
except mariadb.Error as e:
|
except mariadb.Error as e:
|
||||||
print(str(e))
|
print(str(e))
|
||||||
|
|
||||||
def getOneBusiness(self, business_id, enc_key = None):
|
def getOneBusiness(self, business_id, enc_key=None):
|
||||||
try:
|
try:
|
||||||
if self.__cur:
|
if self.__cur:
|
||||||
self.__cur.callproc("getCustomer", (business_id, enc_key,))
|
self.__cur.callproc("getCustomer", (business_id, enc_key,))
|
||||||
#self.__all_cols = [desc[0] for desc in self.__cur.description]
|
# 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:
|
else:
|
||||||
return None #, None
|
return None # , None
|
||||||
except mariadb.Error as e:
|
except mariadb.Error as e:
|
||||||
print(str(e))
|
print(str(e))
|
||||||
|
|
||||||
@@ -47,10 +47,3 @@ class BusinessDAO(QObject):
|
|||||||
|
|
||||||
except mariadb.Error as e:
|
except mariadb.Error as e:
|
||||||
print(str(e))
|
print(str(e))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ class BusinessModel(QAbstractTableModel):
|
|||||||
super().__init__()
|
super().__init__()
|
||||||
self.__business_dao = BusinessDAO()
|
self.__business_dao = BusinessDAO()
|
||||||
self.__business_dao.newBusinessAdded.connect(self.__refreshView)
|
self.__business_dao.newBusinessAdded.connect(self.__refreshView)
|
||||||
self.__conf = ConfigLoader().getConfig()
|
self.__conf = ConfigLoader().get_config()
|
||||||
self.__key = self.__conf['pyqcrm']['ENCRYPTION_KEY']
|
self.__key = self.__conf['pyqcrm']['ENCRYPTION_KEY']
|
||||||
self.__getData()
|
self.__getData()
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
from .DbManager import DbManager
|
|
||||||
from PySide6.QtCore import QObject, Signal
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
import mariadb
|
import mariadb
|
||||||
|
from PySide6.QtCore import QObject, Signal
|
||||||
|
|
||||||
|
from lib.domain.BaseModel import database
|
||||||
|
|
||||||
|
|
||||||
class ContactDAO(QObject):
|
class ContactDAO(QObject):
|
||||||
@@ -9,8 +11,7 @@ class ContactDAO(QObject):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
#print(f"*** File: {__file__}, __init__()")
|
self.__con = database.connection()
|
||||||
self.__con = DbManager().getConnection()
|
|
||||||
if self.__con:
|
if self.__con:
|
||||||
self.__cur = self.__con.cursor()
|
self.__cur = self.__con.cursor()
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class ContactModel(QObject):
|
|||||||
super().__init__()
|
super().__init__()
|
||||||
# print(f"*** File: {__file__}, __init__()")
|
# print(f"*** File: {__file__}, __init__()")
|
||||||
#self.logger = logging.getLogger()
|
#self.logger = logging.getLogger()
|
||||||
self.__conf = ConfigLoader().getConfig()
|
self.__conf = ConfigLoader().get_config()
|
||||||
self.__key = self.__conf['pyqcrm']['ENCRYPTION_KEY']
|
self.__key = self.__conf['pyqcrm']['ENCRYPTION_KEY']
|
||||||
self.__contact_dao = ContactDAO()
|
self.__contact_dao = ContactDAO()
|
||||||
self.__contact_dao.newObjectContactAdded.connect(self.objectContactAdded)
|
self.__contact_dao.newObjectContactAdded.connect(self.objectContactAdded)
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
import mariadb
|
|
||||||
|
|
||||||
class DbManager():
|
|
||||||
__connection = None
|
|
||||||
__con_param = None
|
|
||||||
__dbmanager = None
|
|
||||||
|
|
||||||
def __new__(cls, dbconf = None):
|
|
||||||
|
|
||||||
if cls.__dbmanager is None:
|
|
||||||
cls.__dbmanager = super(DbManager, cls).__new__(cls)
|
|
||||||
cls.__dbmanager.__initializeConfig(dbconf)
|
|
||||||
|
|
||||||
return cls.__dbmanager
|
|
||||||
|
|
||||||
def getConnection(cls):
|
|
||||||
#print(f"DB Manager: {cls.__dbmanager}")
|
|
||||||
#print(f"DB Connection: {cls.__connection}")
|
|
||||||
try:
|
|
||||||
if not cls.__connection or not cls.__connection.ping():
|
|
||||||
cls.__failure_notified = False
|
|
||||||
cls.__connection = mariadb.connect(**cls.__con_param)
|
|
||||||
except mariadb.InterfaceError as e:
|
|
||||||
cls.__connection = mariadb.connect(**cls.__con_param)
|
|
||||||
print(f"DbManager Connection (INTERFACE ERROR): {e}..reconnecting...")
|
|
||||||
except mariadb.Error as e:
|
|
||||||
if '(110)' in str(e):
|
|
||||||
print(f"File: {__file__}\n Database connection timed out (Check connection parameters or server running): {e}")
|
|
||||||
elif '(138)' in str(e):
|
|
||||||
print(f"File: {__file__}\n Database connection timed out (Check connection parameters or server running - initial handshake): {e}")
|
|
||||||
else:
|
|
||||||
print(f"File: {__file__}\n Database connection error: {e}")
|
|
||||||
cls.__connection = None
|
|
||||||
|
|
||||||
return cls.__connection
|
|
||||||
|
|
||||||
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, 'autocommit': True,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,45 +1,41 @@
|
|||||||
from .DbManager import DbManager
|
|
||||||
import json
|
import json
|
||||||
import mariadb
|
|
||||||
from PySide6.QtCore import QObject, Signal
|
from PySide6.QtCore import QObject, Signal
|
||||||
|
|
||||||
|
from lib.domain.BaseModel import database
|
||||||
|
|
||||||
|
|
||||||
class EmployeeDAO(QObject):
|
class EmployeeDAO(QObject):
|
||||||
newEmployeeAdded = Signal(bool)
|
newEmployeeAdded = Signal(bool)
|
||||||
|
|
||||||
__cur = None
|
|
||||||
__all_cols = None
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.__con = DbManager().getConnection()
|
self._connection = database.connection()
|
||||||
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):
|
||||||
|
cursor = self._connection.cursor()
|
||||||
try:
|
try:
|
||||||
if self.__cur:
|
cursor.callproc("getEmployeeTable", (criterion, processed, fired, every_state, enc_key,))
|
||||||
self.__cur.callproc("getEmployeeTable", (criterion, processed, fired, every_state, enc_key,))
|
all_cols = [desc[0] for desc in cursor.description]
|
||||||
self.__all_cols = [desc[0] for desc in self.__cur.description]
|
result = cursor.fetchall(), all_cols
|
||||||
return self.__cur.fetchall(), self.__all_cols
|
return result
|
||||||
else:
|
finally:
|
||||||
return None, None
|
cursor.close()
|
||||||
except mariadb.Error as e:
|
|
||||||
print(str(e))
|
|
||||||
|
|
||||||
def getEmployee(self, employee_id, enc_key=None):
|
def fetchApplicant(self, employee_id, enc_key=None) -> dict:
|
||||||
|
cursor = self._connection.cursor(dictionary=True)
|
||||||
try:
|
try:
|
||||||
if self.__cur:
|
cursor.callproc("getApplicant", (employee_id, enc_key))
|
||||||
self.__cur.callproc("getEmployee", (employee_id, enc_key,))
|
it = cursor.fetchone()
|
||||||
# self.__all_cols = [desc[0] for desc in self.__cur.description]
|
return it
|
||||||
return self.__cur.fetchall() # , self.__all_cols
|
finally:
|
||||||
else:
|
cursor.close()
|
||||||
return None
|
|
||||||
except mariadb.Error as e:
|
|
||||||
print(str(e))
|
|
||||||
|
|
||||||
def addEmployee(self, data, enc_key, applicant=True):
|
def addApplicant(self, data, enc_key, applicant=True):
|
||||||
if self.__cur:
|
cursor = self._connection.cursor()
|
||||||
self.__cur.callproc("addApplicant", (json.dumps(data), applicant, enc_key,))
|
try:
|
||||||
self.__con.commit()
|
cursor.callproc("addApplicant", (json.dumps(data), applicant, enc_key,))
|
||||||
|
self._connection.commit()
|
||||||
self.newEmployeeAdded.emit(True)
|
self.newEmployeeAdded.emit(True)
|
||||||
|
finally:
|
||||||
|
cursor.close()
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
import json
|
from PySide6.QtCore import QAbstractTableModel, QModelIndex, Qt, Slot, Signal
|
||||||
|
|
||||||
from PySide6.QtCore import QAbstractTableModel, QModelIndex, Qt, Slot, Signal, QJsonDocument
|
|
||||||
from PySide6.QtQml import QJSValue
|
from PySide6.QtQml import QJSValue
|
||||||
|
|
||||||
from .EmployeeDAO import EmployeeDAO
|
from .EmployeeDAO import EmployeeDAO
|
||||||
# from ..PyqcrmFlags import PyqcrmFlags, PyqcrmAppliEmpyFlags
|
|
||||||
from ..ConfigLoader import ConfigLoader
|
from ..ConfigLoader import ConfigLoader
|
||||||
import re
|
import re
|
||||||
|
|
||||||
@@ -13,7 +10,6 @@ class EmployeeModel(QAbstractTableModel):
|
|||||||
addedNewEmployee = Signal(bool)
|
addedNewEmployee = Signal(bool)
|
||||||
__data = None
|
__data = None
|
||||||
__employee_dao = None
|
__employee_dao = None
|
||||||
__visible_index = None
|
|
||||||
__visible_columns = None
|
__visible_columns = None
|
||||||
__col_name = ""
|
__col_name = ""
|
||||||
__col_skip = 2
|
__col_skip = 2
|
||||||
@@ -23,7 +19,7 @@ class EmployeeModel(QAbstractTableModel):
|
|||||||
super().__init__()
|
super().__init__()
|
||||||
self.__employee_dao = EmployeeDAO()
|
self.__employee_dao = EmployeeDAO()
|
||||||
self.__employee_dao.newEmployeeAdded.connect(self.__refreshView)
|
self.__employee_dao.newEmployeeAdded.connect(self.__refreshView)
|
||||||
self.__conf = ConfigLoader().getConfig()
|
self.__conf = ConfigLoader().get_config()
|
||||||
self.__key = self.__conf['pyqcrm']['ENCRYPTION_KEY']
|
self.__key = self.__conf['pyqcrm']['ENCRYPTION_KEY']
|
||||||
self.__getData()
|
self.__getData()
|
||||||
|
|
||||||
@@ -32,11 +28,11 @@ class EmployeeModel(QAbstractTableModel):
|
|||||||
if 'worklicense' in new_employee:
|
if 'worklicense' in new_employee:
|
||||||
new_employee['worklicense'] = int(new_employee['worklicense'])
|
new_employee['worklicense'] = int(new_employee['worklicense'])
|
||||||
new_employee['residencetype'] = int(new_employee['residencetype'])
|
new_employee['residencetype'] = int(new_employee['residencetype'])
|
||||||
self.__employee_dao.addEmployee(new_employee, self.__key, False)
|
self.__employee_dao.addApplicant(new_employee, self.__key, False)
|
||||||
|
|
||||||
@Slot(QJSValue)
|
@Slot(QJSValue)
|
||||||
def addApplicant(self, applicant: QJSValue):
|
def addApplicant(self, applicant: QJSValue):
|
||||||
self.__employee_dao.addEmployee({
|
self.__employee_dao.addApplicant({
|
||||||
"city": applicant.property("city").toString(),
|
"city": applicant.property("city").toString(),
|
||||||
"email": applicant.property("email").toString(),
|
"email": applicant.property("email").toString(),
|
||||||
"firstname": applicant.property("firstname").toString(),
|
"firstname": applicant.property("firstname").toString(),
|
||||||
@@ -75,35 +71,21 @@ class EmployeeModel(QAbstractTableModel):
|
|||||||
self.__col_skip = 2
|
self.__col_skip = 2
|
||||||
self.__getData(criterion, criterion == 'Erledigt', False, criterion == 'Alle')
|
self.__getData(criterion, criterion == 'Erledigt', False, criterion == 'Alle')
|
||||||
|
|
||||||
def data(self, index, role=Qt.DisplayRole):
|
def data(self, index, role=Qt.ItemDataRole.DisplayRole):
|
||||||
if role == Qt.DisplayRole:
|
if role == Qt.ItemDataRole.DisplayRole:
|
||||||
row = self.__data[index.row()]
|
row = self.__data[index.row()]
|
||||||
applicant_col = index.column() + self.__col_skip
|
applicant_col = index.column() + self.__col_skip
|
||||||
tr = row[
|
tr = row[applicant_col]
|
||||||
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:
|
if applicant_col == 2 and self.__everyone:
|
||||||
tr = 'Ja' if tr == 1 else 'Nein'
|
tr = 'Ja' if tr == 1 else 'Nein'
|
||||||
else:
|
else:
|
||||||
if tr:
|
if tr:
|
||||||
tr = re.sub("Keine Angabe ", "", tr)
|
tr = re.sub("Keine Angabe ", "", tr)
|
||||||
# print(f"Data: {tr}")
|
|
||||||
# return row[index.column() + 2]
|
|
||||||
return tr
|
return tr
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def headerData(self, section, orientation, role=Qt.DisplayRole):
|
def headerData(self, section, orientation, role=Qt.ItemDataRole.DisplayRole):
|
||||||
if orientation == Qt.Horizontal and role == Qt.DisplayRole:
|
if orientation == Qt.Orientation.Horizontal and role == Qt.ItemDataRole.DisplayRole:
|
||||||
self.__col_name = self.__visible_columns[section + self.__col_skip]
|
self.__col_name = self.__visible_columns[section + self.__col_skip]
|
||||||
return self.__col_name
|
return self.__col_name
|
||||||
return super().headerData(section, orientation, role)
|
return super().headerData(section, orientation, role)
|
||||||
|
|
||||||
@Slot(int)
|
|
||||||
def onRowClicked(self, row):
|
|
||||||
# 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)
|
|
||||||
|
|||||||
@@ -1,17 +1,14 @@
|
|||||||
from .DbManager import DbManager
|
|
||||||
import json
|
import json
|
||||||
import mariadb
|
import mariadb
|
||||||
from PySide6.QtCore import QObject, Signal
|
from PySide6.QtCore import QObject, Signal
|
||||||
# from ..PyqcrmFlags import PyqcrmAppliEmpyFlags
|
from lib.domain.BaseModel import database
|
||||||
|
|
||||||
|
|
||||||
class ObjectDAO(QObject):
|
class ObjectDAO(QObject):
|
||||||
newObjectAdded = Signal(bool, int)
|
newObjectAdded = Signal(bool, int)
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
#print(f"*** File: {__file__}, __init__()")
|
self.__con = database.connection()
|
||||||
self.__con = DbManager().getConnection()
|
|
||||||
if self.__con:
|
if self.__con:
|
||||||
self.__cur = self.__con.cursor()
|
self.__cur = self.__con.cursor()
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class ObjectModel(QAbstractTableModel):
|
|||||||
super().__init__()
|
super().__init__()
|
||||||
self.__object_dao = ObjectDAO()
|
self.__object_dao = ObjectDAO()
|
||||||
self.__object_dao.newObjectAdded.connect(self.__refreshView)
|
self.__object_dao.newObjectAdded.connect(self.__refreshView)
|
||||||
self.__conf = ConfigLoader().getConfig()
|
self.__conf = ConfigLoader().get_config()
|
||||||
self.__key = self.__conf['pyqcrm']['ENCRYPTION_KEY']
|
self.__key = self.__conf['pyqcrm']['ENCRYPTION_KEY']
|
||||||
self.__object_dao.newObjectAdded.connect(self.objectAdded)
|
self.__object_dao.newObjectAdded.connect(self.objectAdded)
|
||||||
self.__getData()
|
self.__getData()
|
||||||
|
|||||||
@@ -1,20 +1,21 @@
|
|||||||
# This Python file uses the following encoding: utf-8
|
# This Python file uses the following encoding: utf-8
|
||||||
from .DbManager import DbManager
|
|
||||||
from ..PyqcrmFlags import PyqcrmFlags
|
from ..PyqcrmFlags import PyqcrmFlags
|
||||||
import mariadb
|
import mariadb
|
||||||
from PySide6.QtCore import QObject, Signal
|
from PySide6.QtCore import QObject, Signal
|
||||||
|
from lib.domain.BaseModel import database
|
||||||
|
|
||||||
|
|
||||||
class UserDAO(QObject):
|
class UserDAO(QObject):
|
||||||
noDbConnection = Signal(str)
|
noDbConnection = Signal(str)
|
||||||
__cursor = None
|
__cursor = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
#print(f"*** File: {__file__}, init()")
|
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.__con = DbManager().getConnection()
|
self.__con = database.connection()
|
||||||
if self.__con:
|
if self.__con:
|
||||||
self.__cur = self.__con.cursor()
|
self.__cur = self.__con.cursor()
|
||||||
|
|
||||||
def createUser(self, username, password, info, role= PyqcrmFlags.USER):
|
def createUser(self, username, password, info, role=PyqcrmFlags.USER):
|
||||||
user_created = False
|
user_created = False
|
||||||
try:
|
try:
|
||||||
if self.__cur:
|
if self.__cur:
|
||||||
@@ -39,6 +40,3 @@ class UserDAO(QObject):
|
|||||||
except mariadb.Error as e:
|
except mariadb.Error as e:
|
||||||
print(str(e))
|
print(str(e))
|
||||||
self.noDbConnection.emit(str(e))
|
self.noDbConnection.emit(str(e))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,35 +1,28 @@
|
|||||||
from .DbManager import DbManager
|
from PySide6.QtCore import Slot, QObject, Signal
|
||||||
|
|
||||||
|
from lib.domain.BaseModel import database
|
||||||
|
from .UserDAO import UserDAO
|
||||||
from ..PyqcrmFlags import PyqcrmFlags
|
from ..PyqcrmFlags import PyqcrmFlags
|
||||||
from ..Vermasseln import Vermasseln
|
from ..Vermasseln import Vermasseln
|
||||||
#from PySide6.QtMultimedia import QMediaPlayer, QAudioOutput : Not working well with Nuitka
|
|
||||||
import soundfile as sf
|
|
||||||
import sounddevice as sd
|
|
||||||
from .UserDAO import UserDAO
|
|
||||||
from PySide6.QtCore import Slot, QObject, Signal, QUrl, QFile
|
|
||||||
import tempfile
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class UserManager(QObject):
|
class UserManager(QObject):
|
||||||
|
|
||||||
loginOkay = Signal()
|
loginOkay = Signal()
|
||||||
noDbConnection = Signal(str)
|
noDbConnection = Signal(str)
|
||||||
|
|
||||||
def __init__(self, user_config = None, role = None):
|
def __init__(self, user_config=None, role=None):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.__con = DbManager().getConnection()
|
self.__con = database.connection()
|
||||||
self.__user_dao = UserDAO()
|
self.__user_dao = UserDAO()
|
||||||
self.__user_dao.noDbConnection.connect(self.noDbConnection)
|
self.__user_dao.noDbConnection.connect(self.noDbConnection)
|
||||||
if self.__con:
|
if self.__con:
|
||||||
self.__cur = self.__con.cursor()
|
self.__cur = self.__con.cursor()
|
||||||
if user_config and role:
|
if user_config and role:
|
||||||
|
|
||||||
self.__username = user_config["PYQCRM_USER"]
|
self.__username = user_config["PYQCRM_USER"]
|
||||||
self.__password = user_config["PYQCRM_USER_PASS"]
|
self.__password = user_config["PYQCRM_USER_PASS"]
|
||||||
self.__info = user_config["PYQCRM_USER_INFO"]
|
self.__info = user_config["PYQCRM_USER_INFO"]
|
||||||
self.__role = role if role == PyqcrmFlags.ADMIN else 0
|
self.__role = role if role == PyqcrmFlags.ADMIN else 0
|
||||||
|
|
||||||
|
|
||||||
def createUser(self):
|
def createUser(self):
|
||||||
self.__hashPassword()
|
self.__hashPassword()
|
||||||
user_created = self.__user_dao.createUser(self.__username, self.__password, self.__info, self.__role)
|
user_created = self.__user_dao.createUser(self.__username, self.__password, self.__info, self.__role)
|
||||||
@@ -64,25 +57,6 @@ class UserManager(QObject):
|
|||||||
user = self.__user_dao.getUser(username)
|
user = self.__user_dao.getUser(username)
|
||||||
if user:
|
if user:
|
||||||
self.__checkPassword(password, user[2])
|
self.__checkPassword(password, user[2])
|
||||||
else:
|
|
||||||
fail_src = ":/sounds/fail2c.ogg"
|
|
||||||
with tempfile.NamedTemporaryFile(suffix='.ogg') as ogg_file:
|
|
||||||
failure_sound = QFile(fail_src)
|
|
||||||
if not failure_sound.open(QFile.ReadOnly):
|
|
||||||
print(f"Failed to open resource file: {fail_src}")
|
|
||||||
else:
|
|
||||||
ogg_file.write(failure_sound.readAll())
|
|
||||||
ogg_path = ogg_file.name
|
|
||||||
fail, samplerate = sf.read(ogg_path)
|
|
||||||
sd.play(fail, samplerate)
|
|
||||||
|
|
||||||
### Not working with Nuitka
|
|
||||||
# player = QMediaPlayer(self)
|
|
||||||
# audioOutput = QAudioOutput(self)
|
|
||||||
# player.setAudioOutput(audioOutput)
|
|
||||||
# player.setSource(QUrl("qrc:/sounds/fail2c.ogg"))
|
|
||||||
# audioOutput.setVolume(150)
|
|
||||||
# player.play()
|
|
||||||
|
|
||||||
def __checkPassword(self, password, hash_password):
|
def __checkPassword(self, password, hash_password):
|
||||||
pw_list = hash_password.split("$")
|
pw_list = hash_password.split("$")
|
||||||
@@ -90,6 +64,3 @@ class UserManager(QObject):
|
|||||||
hash_pw = Vermasseln.userPasswordHash(password, pw_list[0])
|
hash_pw = Vermasseln.userPasswordHash(password, pw_list[0])
|
||||||
if hash_password == hash_pw:
|
if hash_password == hash_pw:
|
||||||
self.loginOkay.emit()
|
self.loginOkay.emit()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
44
lib/domain/Applicant.py
Normal file
44
lib/domain/Applicant.py
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
from peewee import CharField, UUIDField, SmallIntegerField, TextField, ForeignKeyField, JOIN
|
||||||
|
|
||||||
|
from lib.domain.Town import Town
|
||||||
|
from lib.domain.BaseModel import BaseModel
|
||||||
|
from lib.domain.ZipCode import ZipCode
|
||||||
|
|
||||||
|
|
||||||
|
class Applicant(BaseModel):
|
||||||
|
class Meta:
|
||||||
|
table_name = "applicants"
|
||||||
|
|
||||||
|
id = UUIDField(primary_key=True)
|
||||||
|
title = SmallIntegerField(default=0)
|
||||||
|
first_name = CharField(null=False)
|
||||||
|
last_name = CharField(null=False)
|
||||||
|
street = CharField()
|
||||||
|
house_number = CharField()
|
||||||
|
zip_code = ForeignKeyField(ZipCode, column_name="zip_code", null=True)
|
||||||
|
phone_number = CharField()
|
||||||
|
mobile_number = CharField()
|
||||||
|
email_address = CharField()
|
||||||
|
salutation = TextField(null=False)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def select_table_data(cls, search_query: str):
|
||||||
|
return (
|
||||||
|
Applicant
|
||||||
|
.select(
|
||||||
|
Applicant.id,
|
||||||
|
Applicant.first_name,
|
||||||
|
Applicant.last_name,
|
||||||
|
ZipCode.id,
|
||||||
|
ZipCode.zip_code,
|
||||||
|
Town.town
|
||||||
|
)
|
||||||
|
.join(ZipCode, join_type="LEFT JOIN")
|
||||||
|
.join(Town, join_type="LEFT JOIN")
|
||||||
|
.where(
|
||||||
|
(Applicant.first_name.contains(search_query)) |
|
||||||
|
(Applicant.last_name.contains(search_query)) |
|
||||||
|
(ZipCode.zip_code.contains(search_query)) |
|
||||||
|
(Town.town.contains(search_query))
|
||||||
|
)
|
||||||
|
)
|
||||||
22
lib/domain/BaseModel.py
Normal file
22
lib/domain/BaseModel.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
from peewee import Model, MySQLDatabase
|
||||||
|
|
||||||
|
from lib.Config import DatabaseConfig
|
||||||
|
|
||||||
|
database: MySQLDatabase = MySQLDatabase(None)
|
||||||
|
|
||||||
|
|
||||||
|
def init_database_from_config(config: DatabaseConfig):
|
||||||
|
database.init(
|
||||||
|
host=config['DB_HOST'],
|
||||||
|
user=config['DB_USER'],
|
||||||
|
password=config['DB_PASS'],
|
||||||
|
database=config['DB_NAME'],
|
||||||
|
port=int(config['DB_PORT']),
|
||||||
|
connect_timeout=5,
|
||||||
|
)
|
||||||
|
database.connect()
|
||||||
|
|
||||||
|
|
||||||
|
class BaseModel(Model):
|
||||||
|
class Meta:
|
||||||
|
database = database
|
||||||
14
lib/domain/Country.py
Normal file
14
lib/domain/Country.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
from peewee import AutoField, CharField
|
||||||
|
|
||||||
|
from lib.domain.BaseModel import BaseModel
|
||||||
|
|
||||||
|
|
||||||
|
class Country(BaseModel):
|
||||||
|
class Meta:
|
||||||
|
table_name = "country"
|
||||||
|
id = AutoField(column_name="countryid")
|
||||||
|
name = CharField(max_length=200, unique=True)
|
||||||
|
name_short = CharField(max_length=100, column_name="countryshort")
|
||||||
|
nationality = CharField(max_length=100)
|
||||||
|
iso2 = CharField(max_length=2, unique=True)
|
||||||
|
iso3 = CharField(max_length=3, unique=True)
|
||||||
12
lib/domain/Town.py
Normal file
12
lib/domain/Town.py
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
from peewee import AutoField, CharField, ForeignKeyField
|
||||||
|
|
||||||
|
from lib.domain.BaseModel import BaseModel
|
||||||
|
from lib.domain.Country import Country
|
||||||
|
|
||||||
|
|
||||||
|
class Town(BaseModel):
|
||||||
|
class Meta:
|
||||||
|
table_name = "address"
|
||||||
|
id = AutoField(column_name="addressid")
|
||||||
|
town = CharField(max_length=50, column_name="city")
|
||||||
|
country = ForeignKeyField(Country, column_name="countryid", backref="towns")
|
||||||
13
lib/domain/ZipCode.py
Normal file
13
lib/domain/ZipCode.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
from peewee import AutoField, CharField, ForeignKeyField
|
||||||
|
|
||||||
|
from lib.domain.BaseModel import BaseModel
|
||||||
|
from lib.domain.Town import Town
|
||||||
|
|
||||||
|
|
||||||
|
class ZipCode(BaseModel):
|
||||||
|
class Meta:
|
||||||
|
table_name = "postcode"
|
||||||
|
|
||||||
|
id = AutoField(column_name="postcodeid")
|
||||||
|
zip_code = CharField(max_length=15, column_name="postcode")
|
||||||
|
town = ForeignKeyField(Town, backref="zip_codes", column_name="addressid")
|
||||||
57
main.py
57
main.py
@@ -1,44 +1,35 @@
|
|||||||
# # !/home/linuxero/proj/tero/pyqcrm/.qtcreator/venv-3.13.1/bin/python3
|
# # !/home/linuxero/proj/tero/pyqcrm/.qtcreator/venv-3.13.1/bin/python3
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import logging
|
# noinspection PyUnresolvedReferences
|
||||||
from PySide6.QtNetwork import QLocalServer, QLocalSocket
|
|
||||||
from PySide6.QtWidgets import QSystemTrayIcon
|
|
||||||
from PySide6.QtGui import QGuiApplication, QIcon
|
|
||||||
from PySide6.QtQml import QQmlApplicationEngine
|
|
||||||
from PySide6.QtCore import QIODevice
|
|
||||||
from lib.ConfigLoader import ConfigLoader
|
|
||||||
from lib.DB.BusinessModel import BusinessModel
|
|
||||||
import rc_pyqcrm
|
import rc_pyqcrm
|
||||||
|
# noinspection PyUnresolvedReferences
|
||||||
import rc_qml
|
import rc_qml
|
||||||
from lib.DB.DbManager import DbManager
|
|
||||||
from lib.DB.UserManager import UserManager
|
from PySide6.QtCore import QIODevice
|
||||||
|
from PySide6.QtGui import QGuiApplication, QIcon
|
||||||
|
from PySide6.QtNetwork import QLocalServer, QLocalSocket
|
||||||
|
from PySide6.QtQml import QQmlApplicationEngine
|
||||||
|
from PySide6.QtWidgets import QSystemTrayIcon
|
||||||
|
|
||||||
|
from lib.ConfigLoader import ConfigLoader
|
||||||
from lib.DB.AddressModel import AddressModel
|
from lib.DB.AddressModel import AddressModel
|
||||||
|
from lib.DB.ApplicantModel import ApplicantModel
|
||||||
from lib.DB.BTypeModel import BTypeModel
|
from lib.DB.BTypeModel import BTypeModel
|
||||||
|
from lib.DB.BusinessModel import BusinessModel
|
||||||
from lib.DB.ContactModel import ContactModel
|
from lib.DB.ContactModel import ContactModel
|
||||||
from lib.DB.EmployeeModel import EmployeeModel
|
from lib.DB.EmployeeModel import EmployeeModel
|
||||||
from lib.DB.ObjectModel import ObjectModel
|
from lib.DB.ObjectModel import ObjectModel
|
||||||
|
from lib.DB.UserManager import UserManager
|
||||||
from lib.Printers import Printers
|
from lib.Printers import Printers
|
||||||
|
from lib.domain.BaseModel import database, init_database_from_config
|
||||||
|
|
||||||
os.environ['QML_XHR_ALLOW_FILE_READ'] = '1'
|
os.environ['QML_XHR_ALLOW_FILE_READ'] = '1'
|
||||||
|
|
||||||
|
|
||||||
# [pyqcrm]
|
|
||||||
# program-name=""
|
|
||||||
# version=
|
|
||||||
|
|
||||||
# [database]
|
|
||||||
# server=""
|
|
||||||
# port=
|
|
||||||
# user=""
|
|
||||||
# password=""
|
|
||||||
# name=""
|
|
||||||
# type=""
|
|
||||||
|
|
||||||
|
|
||||||
bad_config = False
|
bad_config = False
|
||||||
db_con = False
|
db_con = False
|
||||||
address_model = None
|
address_model = None
|
||||||
|
applicant_model = None
|
||||||
business_model = None
|
business_model = None
|
||||||
business_type = None
|
business_type = None
|
||||||
contact_model = None
|
contact_model = None
|
||||||
@@ -49,17 +40,17 @@ user = None
|
|||||||
|
|
||||||
|
|
||||||
def initializeProgram():
|
def initializeProgram():
|
||||||
print(f"In {__file__} file, initializeProgram()")
|
global address_model, applicant_model, bad_config, business_model, user, business_type, contact_model, employee_model, object_model, db_con, printers
|
||||||
global address_model, bad_config, business_model, user, business_type, contact_model, employee_model, object_model, db_con, printers
|
|
||||||
if not bad_config:
|
if not bad_config:
|
||||||
dbconf = config.getConfig()['database']
|
init_database_from_config(config.get_config()['database'])
|
||||||
DbManager(dbconf)
|
|
||||||
printers = Printers()
|
printers = Printers()
|
||||||
if DbManager().getConnection():
|
if not database.is_closed():
|
||||||
db_con = True
|
db_con = True
|
||||||
user = UserManager()
|
user = UserManager()
|
||||||
business_model = BusinessModel()
|
business_model = BusinessModel()
|
||||||
address_model = AddressModel()
|
address_model = AddressModel()
|
||||||
|
applicant_model = ApplicantModel()
|
||||||
business_type = BTypeModel()
|
business_type = BTypeModel()
|
||||||
contact_model = ContactModel()
|
contact_model = ContactModel()
|
||||||
employee_model = EmployeeModel()
|
employee_model = EmployeeModel()
|
||||||
@@ -74,11 +65,11 @@ def configReady():
|
|||||||
|
|
||||||
|
|
||||||
def publishContext():
|
def publishContext():
|
||||||
# print(f"In {__file__} file, publishContext()")
|
global engine, address_model, applicant_model, bad_config, business_model, user, business_type, contact_model, object_model, employee_model, printers
|
||||||
global engine, address_model, bad_config, business_model, user, business_type, contact_model, object_model, employee_model, printers
|
|
||||||
engine.rootContext().setContextProperty("loggedin_user", user)
|
engine.rootContext().setContextProperty("loggedin_user", user)
|
||||||
engine.rootContext().setContextProperty("business_model", business_model)
|
engine.rootContext().setContextProperty("business_model", business_model)
|
||||||
engine.rootContext().setContextProperty("address_model", address_model)
|
engine.rootContext().setContextProperty("address_model", address_model)
|
||||||
|
engine.rootContext().setContextProperty("applicantModel", applicant_model)
|
||||||
engine.rootContext().setContextProperty("business_type", business_type)
|
engine.rootContext().setContextProperty("business_type", business_type)
|
||||||
engine.rootContext().setContextProperty("contact_model", contact_model)
|
engine.rootContext().setContextProperty("contact_model", contact_model)
|
||||||
engine.rootContext().setContextProperty("employee_model", employee_model)
|
engine.rootContext().setContextProperty("employee_model", employee_model)
|
||||||
@@ -105,7 +96,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
qml_file = "qrc:/Gui/main.qml"
|
qml_file = "qrc:/Gui/main.qml"
|
||||||
|
|
||||||
icon = QIcon(":/images/tero.jpg")
|
icon = QIcon("qrc:/images/tero.jpg")
|
||||||
app.setWindowIcon(icon)
|
app.setWindowIcon(icon)
|
||||||
|
|
||||||
tray = QSystemTrayIcon()
|
tray = QSystemTrayIcon()
|
||||||
@@ -114,7 +105,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
config = ConfigLoader()
|
config = ConfigLoader()
|
||||||
|
|
||||||
if not config.getConfig():
|
if not config.get_config():
|
||||||
bad_config = True
|
bad_config = True
|
||||||
config.configurationReady.connect(configReady)
|
config.configurationReady.connect(configReady)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
"lib/DB/BusinessModel.py",
|
"lib/DB/BusinessModel.py",
|
||||||
"pyqcrm.qrc",
|
"pyqcrm.qrc",
|
||||||
"qml.qrc",
|
"qml.qrc",
|
||||||
"lib/DB/DbManager.py",
|
|
||||||
"lib/DB/UserManager.py",
|
"lib/DB/UserManager.py",
|
||||||
"lib/PyqcrmFlags.py",
|
"lib/PyqcrmFlags.py",
|
||||||
"lib/DB/UserDAO.py",
|
"lib/DB/UserDAO.py",
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
<file>images/ChevronDown.svg</file>
|
<file>images/ChevronDown.svg</file>
|
||||||
<file>images/Funnel.svg</file>
|
<file>images/Funnel.svg</file>
|
||||||
<file>images/Identification-Outline.svg</file>
|
<file>images/Identification-Outline.svg</file>
|
||||||
|
<file>images/InboxArrowDown.svg</file>
|
||||||
<file>images/MagnifyingGlass.svg</file>
|
<file>images/MagnifyingGlass.svg</file>
|
||||||
<file>images/Newspaper-Outline.svg</file>
|
<file>images/Newspaper-Outline.svg</file>
|
||||||
<file>images/Phone.svg</file>
|
<file>images/Phone.svg</file>
|
||||||
@@ -19,14 +20,8 @@
|
|||||||
<file>images/UserCircle.svg</file>
|
<file>images/UserCircle.svg</file>
|
||||||
<file>images/UserGroup-Outline.svg</file>
|
<file>images/UserGroup-Outline.svg</file>
|
||||||
<file>images/Wallet-Outline.svg</file>
|
<file>images/Wallet-Outline.svg</file>
|
||||||
<file>sounds/error.ogg</file>
|
|
||||||
<file>sounds/fail2c.ogg</file>
|
|
||||||
<file>sounds/puzzerr.ogg</file>
|
|
||||||
<file>sounds/sysnotify.ogg</file>
|
|
||||||
<file>sounds/wrong.ogg</file>
|
|
||||||
<file>fonts/RobotoCondensed.otf</file>
|
<file>fonts/RobotoCondensed.otf</file>
|
||||||
<file>README</file>
|
<file>README</file>
|
||||||
<file>LICENSE</file>
|
<file>LICENSE</file>
|
||||||
<file>images/tero.jpg</file>
|
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
8
qml.qrc
8
qml.qrc
@@ -39,11 +39,11 @@
|
|||||||
<file>Gui/OffersTable.qml</file>
|
<file>Gui/OffersTable.qml</file>
|
||||||
<file>Gui/Employees/AddApplicant.qml</file>
|
<file>Gui/Employees/AddApplicant.qml</file>
|
||||||
<file>Gui/Employees/AddEmployee.qml</file>
|
<file>Gui/Employees/AddEmployee.qml</file>
|
||||||
<file>Gui/Employees/ApplicantPersonalData.qml</file>
|
|
||||||
<file>Gui/Employees/ApplicantBankData.qml</file>
|
|
||||||
<file>Gui/Employees/ApplicantForm.qml</file>
|
<file>Gui/Employees/ApplicantForm.qml</file>
|
||||||
<file>Gui/Employees/ApplicantNationalInsurance.qml</file>
|
<file>Gui/Employees/EmployeePersonalData.qml</file>
|
||||||
<file>Gui/Employees/ApplicantVarious.qml</file>
|
<file>Gui/Employees/EmployeeBankData.qml</file>
|
||||||
|
<file>Gui/Employees/EmployeeNationalInsurance.qml</file>
|
||||||
|
<file>Gui/Employees/EmployeeVarious.qml</file>
|
||||||
<file>Gui/Employees/EmployeeDetails.qml</file>
|
<file>Gui/Employees/EmployeeDetails.qml</file>
|
||||||
<file>Gui/Employees/EmployeesTable.qml</file>
|
<file>Gui/Employees/EmployeesTable.qml</file>
|
||||||
<file>Gui/Employees/qmldir</file>
|
<file>Gui/Employees/qmldir</file>
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ platformdirs
|
|||||||
pycryptodome
|
pycryptodome
|
||||||
psutil
|
psutil
|
||||||
toml
|
toml
|
||||||
mariadb
|
|
||||||
soundfile
|
soundfile
|
||||||
sounddevice
|
sounddevice
|
||||||
reportlab
|
reportlab
|
||||||
|
peewee
|
||||||
|
pymysql
|
||||||
BIN
sounds/error.aac
BIN
sounds/error.aac
Binary file not shown.
BIN
sounds/error.ac3
BIN
sounds/error.ac3
Binary file not shown.
BIN
sounds/error.mp3
BIN
sounds/error.mp3
Binary file not shown.
BIN
sounds/error.ogg
BIN
sounds/error.ogg
Binary file not shown.
BIN
sounds/error.wav
BIN
sounds/error.wav
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
sounds/wrong.ogg
BIN
sounds/wrong.ogg
Binary file not shown.
Reference in New Issue
Block a user