|
@@ -34,7 +34,13 @@ except ImportError:
|
34
|
34
|
dbus = None
|
35
|
35
|
|
36
|
36
|
from piket_client.sound import PLOP_WAVE, UNDO_WAVE
|
37
|
|
-from piket_client.model import Person, ConsumptionType, Consumption, ServerStatus, Settlement
|
|
37
|
+from piket_client.model import (
|
|
38
|
+ Person,
|
|
39
|
+ ConsumptionType,
|
|
40
|
+ Consumption,
|
|
41
|
+ ServerStatus,
|
|
42
|
+ Settlement,
|
|
43
|
+)
|
38
|
44
|
import piket_client.logger
|
39
|
45
|
|
40
|
46
|
LOG = logging.getLogger(__name__)
|
|
@@ -87,18 +93,17 @@ class NameButton(QPushButton):
|
87
|
93
|
|
88
|
94
|
def process_click(self) -> None:
|
89
|
95
|
""" Process a click on this button. """
|
90
|
|
- LOG.debug('Button clicked.')
|
|
96
|
+ LOG.debug("Button clicked.")
|
91
|
97
|
result = self.person.add_consumption(self.active_id)
|
92
|
98
|
if result:
|
93
|
99
|
plop()
|
94
|
100
|
self.setText(self.current_label)
|
95
|
101
|
self.consumption_created.emit(result)
|
96
|
102
|
else:
|
97
|
|
- LOG.error("Failed to add consumption", extra={'person':
|
98
|
|
- self.person})
|
|
103
|
+ LOG.error("Failed to add consumption", extra={"person": self.person})
|
99
|
104
|
|
100
|
105
|
def confirm_hide(self) -> None:
|
101
|
|
- LOG.debug('Button right-clicked.')
|
|
106
|
+ LOG.debug("Button right-clicked.")
|
102
|
107
|
ok = QMessageBox.warning(
|
103
|
108
|
self.window(),
|
104
|
109
|
"Persoon verbergen?",
|
|
@@ -132,8 +137,7 @@ class NameButtons(QWidget):
|
132
|
137
|
def consumption_type_changed(self, new_id: str):
|
133
|
138
|
""" Process a change of the consumption type and propagate to the
|
134
|
139
|
contained buttons. """
|
135
|
|
- LOG.debug('Consumption type updated in NameButtons.',
|
136
|
|
- extra={'new_id': new_id})
|
|
140
|
+ LOG.debug("Consumption type updated in NameButtons.", extra={"new_id": new_id})
|
137
|
141
|
self.active_consumption_type_id = new_id
|
138
|
142
|
self.new_id_set.emit(new_id)
|
139
|
143
|
|
|
@@ -141,7 +145,7 @@ class NameButtons(QWidget):
|
141
|
145
|
""" Initialize UI: build GridLayout, retrieve People and build a button
|
142
|
146
|
for each. """
|
143
|
147
|
|
144
|
|
- LOG.debug('Initializing NameButtons.')
|
|
148
|
+ LOG.debug("Initializing NameButtons.")
|
145
|
149
|
|
146
|
150
|
ps = Person.get_all(True)
|
147
|
151
|
num_columns = round(len(ps) / 10) + 1
|
|
@@ -170,7 +174,7 @@ class PiketMainWindow(QMainWindow):
|
170
|
174
|
consumption_type_changed = Signal(str)
|
171
|
175
|
|
172
|
176
|
def __init__(self) -> None:
|
173
|
|
- LOG.debug('Initializing PiketMainWindow.')
|
|
177
|
+ LOG.debug("Initializing PiketMainWindow.")
|
174
|
178
|
super().__init__()
|
175
|
179
|
|
176
|
180
|
self.main_widget = None
|
|
@@ -442,40 +446,39 @@ def main() -> None:
|
442
|
446
|
# Test unsettled consumptions
|
443
|
447
|
status = ServerStatus.unsettled_consumptions()
|
444
|
448
|
|
445
|
|
- unsettled = status['unsettled']['amount']
|
|
449
|
+ unsettled = status["unsettled"]["amount"]
|
446
|
450
|
|
447
|
451
|
if unsettled > 0:
|
448
|
|
- first = status['unsettled']['first']
|
449
|
|
- first_date = first.strftime('%c')
|
|
452
|
+ first = status["unsettled"]["first"]
|
|
453
|
+ first_date = first.strftime("%c")
|
450
|
454
|
ok = QMessageBox.information(
|
451
|
455
|
None,
|
452
|
456
|
"Onafgesloten lijst",
|
453
|
457
|
f"Wil je verdergaan met een lijst met {unsettled} onafgesloten "
|
454
|
458
|
f"consumpties sinds {first_date}?",
|
455
|
459
|
QMessageBox.Yes,
|
456
|
|
- QMessageBox.No
|
|
460
|
+ QMessageBox.No,
|
457
|
461
|
)
|
458
|
462
|
if ok == QMessageBox.No:
|
459
|
463
|
main_window.show_keyboard()
|
460
|
464
|
name, ok = QInputDialog.getText(
|
461
|
465
|
None,
|
462
|
466
|
"Lijst afsluiten",
|
463
|
|
- "Voer een naam in voor de lijst of druk op OK. Laat de datum "
|
464
|
|
- "staan.",
|
|
467
|
+ "Voer een naam in voor de lijst of druk op OK. Laat de datum " "staan.",
|
465
|
468
|
QLineEdit.Normal,
|
466
|
|
- f"{first.strftime('%Y-%m-%d')}"
|
|
469
|
+ f"{first.strftime('%Y-%m-%d')}",
|
467
|
470
|
)
|
468
|
471
|
main_window.hide_keyboard()
|
469
|
472
|
|
470
|
473
|
if name and ok:
|
471
|
474
|
settlement = Settlement.create(name)
|
472
|
|
- info = [f'{item["count"]} {item["name"]}' for item in
|
473
|
|
- settlement.consumption_summary.values()]
|
474
|
|
- info = ', '.join(info)
|
|
475
|
+ info = [
|
|
476
|
+ f'{item["count"]} {item["name"]}'
|
|
477
|
+ for item in settlement.consumption_summary.values()
|
|
478
|
+ ]
|
|
479
|
+ info = ", ".join(info)
|
475
|
480
|
QMessageBox.information(
|
476
|
|
- None,
|
477
|
|
- "Lijst afgesloten",
|
478
|
|
- f"VO! Op deze lijst stonden: {info}"
|
|
481
|
+ None, "Lijst afgesloten", f"VO! Op deze lijst stonden: {info}"
|
479
|
482
|
)
|
480
|
483
|
|
481
|
484
|
main_window = PiketMainWindow()
|