コード例 #1
0
 def test_set_permission(self):
     profile = UserProfile(store=self.store, name=u'boss')
     profile.add_application_reference(u'app', False)
     setting = self.store.find(ProfileSettings, user_profile=profile,
                               app_dir_name=u'app').one()
     self.assertFalse(setting.has_permission)
     ProfileSettings.set_permission(self.store, profile, u'app', True)
     self.assertTrue(setting.has_permission)
     ProfileSettings.set_permission(self.store, profile, u'app', False)
     self.assertFalse(setting.has_permission)
コード例 #2
0
ファイル: test_profile.py プロジェクト: romaia/stoq
 def test_set_permission(self):
     profile = UserProfile(store=self.store, name=u'boss')
     profile.add_application_reference(u'app', False)
     setting = self.store.find(ProfileSettings, user_profile=profile,
                                          app_dir_name=u'app').one()
     self.failIf(setting.has_permission)
     ProfileSettings.set_permission(self.store, profile, u'app', True)
     self.failUnless(setting.has_permission)
     ProfileSettings.set_permission(self.store, profile, u'app', False)
     self.failIf(setting.has_permission)
コード例 #3
0
 def create_profile_settings(self, user_profile=None, app=u'admin'):
     from stoqlib.domain.profile import ProfileSettings
     if not user_profile:
         user_profile = self.create_user_profile()
     return ProfileSettings(store=self.store, app_dir_name=app,
                            has_permission=True,
                            user_profile=user_profile)
コード例 #4
0
ファイル: admin.py プロジェクト: romaia/stoq
def create_default_profile_settings():
    store = new_store()
    profile = store.find(UserProfile, name=_(u'Salesperson')).one()
    # Not sure what is happening. If it doesnt exist, check if it was not
    # created in english. workaround for crash report 207 (bug 4587)
    if not profile:
        profile = store.find(UserProfile, name=u'Salesperson').one()
    assert profile
    ProfileSettings.set_permission(store, profile, u'pos', True)
    ProfileSettings.set_permission(store, profile, u'sales', True)
    ProfileSettings.set_permission(store, profile, u'till', True)
    store.commit(close=True)
コード例 #5
0
def create_default_profile_settings():
    store = new_store()
    profile = store.find(UserProfile, name=_(u'Salesperson')).one()
    # Not sure what is happening. If it doesnt exist, check if it was not
    # created in english. workaround for crash report 207 (bug 4587)
    if not profile:
        profile = store.find(UserProfile, name=u'Salesperson').one()
    assert profile
    ProfileSettings.set_permission(store, profile, u'pos', True)
    ProfileSettings.set_permission(store, profile, u'sales', True)
    ProfileSettings.set_permission(store, profile, u'till', True)
    store.commit(close=True)
コード例 #6
0
    def setup_slaves(self):
        settings = {}
        for setting in self.model.profile_settings:
            settings[setting.app_dir_name] = setting

        apps = get_utility(IApplicationDescriptions)
        for name, full_name, icon_name, description in apps.get_descriptions():
            # Virtual apps should not be selected here
            if name in ProfileSettings.virtual_apps:
                continue

            # Create the user interface for each application which is
            # a HBox, a CheckButton and an Image
            box = Gtk.HBox()
            box.show()

            button = ProxyCheckButton()
            button.set_label(full_name)
            button.data_type = bool
            button.model_attribute = 'has_permission'
            button.show()
            box.pack_start(button, True, True, 6)

            image = Gtk.Image.new_from_stock(icon_name, Gtk.IconSize.MENU)
            box.pack_start(image, False, False, 0)
            image.show()

            self.applications_vbox.pack_start(box, False, True, 0)

            model = settings.get(name)
            if model is None:
                model = ProfileSettings(store=self.store,
                                        has_permission=False,
                                        app_dir_name=name,
                                        user_profile=self.model)

            setattr(self, name, button)
            self.add_proxy(model, [name])

        # Scroll to the bottom of the scrolled window
        vadj = self.scrolled_window.get_vadjustment()
        vadj.set_value(vadj.get_upper())