33 lines
1.0 KiB
Python
33 lines
1.0 KiB
Python
from ...utils import defer, http_post
|
|
from . import GetPositionsView
|
|
from ceod.transactions.members.UpdateMemberPositionsTransaction import UpdateMemberPositionsTransaction as PositionsTransactions
|
|
|
|
class SetPositionsView(GetPositionsView):
|
|
def __init__(self, screen, widgets, height, model):
|
|
super().__init__(screen, widgets, height, model, False)
|
|
|
|
|
|
def _add_buttons(self):
|
|
self.add_buttons(
|
|
next_btn_text="Update",
|
|
next_scene='Confirm',
|
|
on_next=self._next,
|
|
back_btn=True,
|
|
)
|
|
|
|
|
|
def _next(self):
|
|
positions = {}
|
|
for pos in self._positions:
|
|
positions[pos.name] = pos.value
|
|
|
|
self._model.deferred_req = defer(http_post, f'/api/positions', json=positions)
|
|
self._model.operations = PositionsTransactions.operations
|
|
self._model.confirm_lines = [
|
|
"The positions will be updated as follows",
|
|
'',
|
|
*positions.items(),
|
|
'',
|
|
'Are you sure you want to continue?',
|
|
]
|