本文整理汇总了Python中stoqlib.lib.permissions.PermissionManager类的典型用法代码示例。如果您正苦于以下问题:Python PermissionManager类的具体用法?Python PermissionManager怎么用?Python PermissionManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PermissionManager类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, wizard, store, model):
WizardEditorStep.__init__(self, store, wizard, model)
pm = PermissionManager.get_permission_manager()
if not pm.can_create('Supplier'):
self.add_supplier.hide()
if not pm.can_edit('Supplier'):
self.edit_supplier.hide()
示例2: _create_actions
def _create_actions(self):
# Gloabl actions avaiable at any time from all applications
actions = [
('preferences', None),
('export', None),
('print', None),
('sign_out', None),
('change_password', None),
('HelpApp', None),
('HelpContents', None),
('HelpTranslate', None),
('HelpSupport', None),
('HelpChat', None),
('HelpAbout', None),
('quit', None),
]
pm = PermissionManager.get_permission_manager()
group = Gio.SimpleActionGroup()
self.toplevel.insert_action_group('stoq', group)
for (name, param_type) in actions:
action = Gio.SimpleAction.new(name, param_type)
group.add_action(action)
# Save the action in self so that auto signal connections work
setattr(self, name, action)
# Check permissions
key, required = self.action_permissions.get(name,
(None, pm.PERM_ALL))
if not pm.get(key) & required:
action.set_enabled(False)
示例3: tearDownClass
def tearDownClass(cls):
"""Undo what is done in the setup on NFeUI
We must do this otherwise it will affect other tests
"""
pm = PermissionManager.get_permission_manager()
pm.set('InvoiceLayout', pm.PERM_ALL)
pm.set('InvoicePrinter', pm.PERM_ALL)
pm.set('app.sales.print_invoice', pm.PERM_ALL)
示例4: setUp
def setUp(self):
super(BaseTest, self).setUp()
# The final interface depends on this
pm = PermissionManager.get_permission_manager()
pm.set('Product', PermissionManager.PERM_ALL)
self.wizard = self.wizard_class(self.store)
self.step = self.step_class(self.wizard, None, self.store, self.wizard.model)
示例5: __init__
def __init__(self):
SaleStatusChangedEvent.connect(self._on_SaleStatusChanged)
pm = PermissionManager.get_permission_manager()
pm.set('InvoiceLayout', pm.PERM_HIDDEN)
pm.set('InvoicePrinter', pm.PERM_HIDDEN)
# since the nfe plugin was enabled, the user must not be able to print
# the regular fiscal invoice (replaced by the nfe).
pm.set('app.sales.print_invoice', pm.PERM_HIDDEN)
示例6: __init__
def __init__(self, store, model=None, visual_mode=False, category=None):
self._default_category = category
self.proxy = None
super(WorkOrderEditor, self).__init__(store, model=model,
visual_mode=visual_mode)
self._setup_widgets()
pm = PermissionManager.get_permission_manager()
if not pm.can_create('WorkOrderCategory'):
self.category_create.hide()
if not pm.can_edit('WorkOrderCategory'):
self.category_edit.hide()
示例7: __init__
def __init__(self):
self._setup_params()
self._setup_events()
pm = PermissionManager.get_permission_manager()
pm.set('InvoiceLayout', pm.PERM_HIDDEN)
pm.set('InvoicePrinter', pm.PERM_HIDDEN)
# since the nfe plugin was enabled, the user must not be able to print
# the regular fiscal invoice (replaced by the nfe).
pm.set('app.sales.print_invoice', pm.PERM_HIDDEN)
self._update_forms()
示例8: __init__
def __init__(self):
SaleReturnWizardFinishEvent.connect(self._on_SaleReturnWizardFinish)
SaleStatusChangedEvent.connect(self._on_SaleStatusChanged)
StockDecreaseWizardFinishEvent.connect(self._on_StockDecreaseWizardFinish)
StockTransferWizardFinishEvent.connect(self._on_StockTransferWizardFinish)
# TODO: Before enable the the NF-e generation. Save the invoice data,
# in Invoice table (for each operation below).
# NewLoanWizardFinishEvent.connect(self._on_NewLoanWizardFinish)
pm = PermissionManager.get_permission_manager()
pm.set('InvoiceLayout', pm.PERM_HIDDEN)
pm.set('InvoicePrinter', pm.PERM_HIDDEN)
# since the nfe plugin was enabled, the user must not be able to print
# the regular fiscal invoice (replaced by the nfe).
pm.set('app.sales.print_invoice', pm.PERM_HIDDEN)
self._update_forms()
示例9: __init__
def __init__(self, store, model=None, visual_mode=False, category=None,
available_categories=None):
"""
@param category: The default category that should be already selected.
@param available_categories: A list of categories names that should be
available to the user. If None, all categoires will be available
"""
self._default_category = category
self.categories_for_combo = available_categories
self.proxy = None
super(WorkOrderEditor, self).__init__(store, model=model,
visual_mode=visual_mode)
self._setup_widgets()
pm = PermissionManager.get_permission_manager()
if not pm.can_create('WorkOrderCategory'):
self.category_create.hide()
if not pm.can_edit('WorkOrderCategory'):
self.category_edit.hide()
示例10: _check_permissions
def _check_permissions(self):
if not self.editor_class:
return
pm = PermissionManager.get_permission_manager()
key = self.editor_class.model_type.__name__
if not pm.can_create(key):
self.hide_new_button()
if not pm.can_edit(key):
if pm.can_see_details(key):
# Replace edit button with a details button. self._read_only
# will activate visual_mode for the editor
self._read_only = True
self._toolbar.edit_button_label.set_text(_('Details'))
self._toolbar.edit_button_image.set_from_stock('gtk-info', gtk.ICON_SIZE_BUTTON)
else:
self.hide_edit_button()
示例11: testShowWithoutPermission
def testShowWithoutPermission(self, run_dialog):
# Our only permission now is to see details
pm = PermissionManager.get_permission_manager()
pm.set('Product', pm.PERM_ONLY_DETAILS)
search = self._show_search()
# New button shoud not be visible and edit button should actually be
# 'Details'
self.assertNotVisible(search._toolbar, ['new_button'])
self.assertSensitive(search._toolbar, ['edit_button'])
self.assertEquals(search._toolbar.edit_button_label.get_label(),
_('Details'))
# Editor should be called with visual mode set.
self.click(search._toolbar.edit_button)
args, kwargs = run_dialog.call_args
self.assertTrue('visual_mode' in kwargs)
self.assertEquals(kwargs['visual_mode'], True)
示例12: tearDown
def tearDown(self):
GUITest.tearDown(self)
# Reset the permitions so they wont influence other tests
pm = PermissionManager.get_permission_manager()
pm.set('Product', PermissionManager.PERM_ALL)