Source code for stoqlib.gui.dialogs.devices

# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4

##
## Copyright (C) 2006, 2008 Async Open Source <http://www.async.com.br>
## All rights reserved
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU Lesser General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU Lesser General Public License for more details.
##
## You should have received a copy of the GNU Lesser General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., or visit: http://www.gnu.org/.
##
## Author(s): Stoq Team <stoq-devel@async.com.br>
##
##
"""Device Settings listing dialog """

from kiwi.ui.objectlist import Column

from stoqlib.database.runtime import get_current_station
from stoqlib.domain.devices import DeviceSettings
from stoqlib.gui.base.lists import ModelListDialog, ModelListSlave
from stoqlib.gui.editors.deviceseditor import DeviceSettingsEditor
from stoqlib.lib.translation import stoqlib_gettext

_ = stoqlib_gettext


[docs]class DeviceSettingsListSlave(ModelListSlave): columns = [ Column('device_type_name', title=_('Device Type'), data_type=str, sorted=True, width=180), Column('description', title=_('Description'), data_type=str, expand=True), Column('station_name', title=_('Computer'), data_type=str, width=150, searchable=True), Column('is_active', title=_("Active"), data_type=bool, width=70)] model_type = DeviceSettings # FIXME: This should be 'def populate', verify if this is working def _populate(self): return self.parent.store.find(DeviceSettings)
[docs] def run_editor(self, store, model): return self.run_dialog(DeviceSettingsEditor, store=store, model=model, station=get_current_station(store))
[docs]class DeviceSettingsDialog(ModelListDialog): list_slave_class = DeviceSettingsListSlave title = _('Device settings') size = (750, 300)
if __name__ == '__main__': # pragma: nocover from stoqlib.gui.base.dialogs import run_dialog from stoqlib.api import api ec = api.prepare_test() retval = run_dialog(DeviceSettingsDialog, None, ec.store) if retval: ec.store.commit() print('RETVAL', retval)