47 lines
1.4 KiB
Python
47 lines
1.4 KiB
Python
from asciimatics.widgets import Layout, Text
|
|
|
|
from ...utils import defer, http_post
|
|
from ..CeoFrame import CeoFrame
|
|
from ceod.transactions.groups import AddGroupTransaction
|
|
|
|
|
|
class AddGroupView(CeoFrame):
|
|
def __init__(self, screen, width, height, model):
|
|
super().__init__(
|
|
screen, height, width, model, 'AddGroup',
|
|
)
|
|
layout = Layout([100], fill_frame=True)
|
|
self.add_layout(layout)
|
|
self._cn = Text('Name:', 'cn')
|
|
layout.add_widget(self._cn)
|
|
self._description = Text('Description:', 'description')
|
|
layout.add_widget(self._description)
|
|
|
|
self.add_buttons(
|
|
back_btn=True,
|
|
next_scene='Confirm', on_next=self._next)
|
|
self.fix()
|
|
|
|
def _ceoframe_on_reset(self):
|
|
super()._ceoframe_on_reset()
|
|
self._cn.value = None
|
|
self._description.value = None
|
|
|
|
def _next(self):
|
|
cn = self._cn.value
|
|
description = self._description.value
|
|
body = {
|
|
'cn': cn,
|
|
'description': description,
|
|
}
|
|
self._model.confirm_lines = [
|
|
'The following group will be created:',
|
|
'',
|
|
('cn', cn),
|
|
('description', description),
|
|
'',
|
|
'Are you sure you want to continue?',
|
|
]
|
|
self._model.deferred_req = defer(http_post, '/api/groups', json=body)
|
|
self._model.operations = AddGroupTransaction.operations
|