当前位置: 首页>>代码示例>>Python>>正文


Python Avatar.getId方法代码示例

本文整理汇总了Python中MaKaC.user.Avatar.getId方法的典型用法代码示例。如果您正苦于以下问题:Python Avatar.getId方法的具体用法?Python Avatar.getId怎么用?Python Avatar.getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MaKaC.user.Avatar的用法示例。


在下文中一共展示了Avatar.getId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _run

# 需要导入模块: from MaKaC.user import Avatar [as 别名]
# 或者: from MaKaC.user.Avatar import getId [as 别名]
    def _run(self, args):
        avatar = Avatar()

        name = raw_input("New administrator name: ").strip()
        surname = raw_input("New administrator surname: ").strip()
        organization = raw_input("New administrator organization: ").strip()
        email = raw_input("New administrator email: ").strip()
        login = raw_input("New administrator login: ").strip()
        password = getpass("New administrator password: ")
        password2 = getpass("Retype administrator password: ")
        if password != password2:
            raise Exception("Sorry, passwords do not match")

        avatar.setName(name)
        avatar.setSurName(surname)
        avatar.setOrganisation(organization)
        avatar.setLang("en_GB")
        avatar.setEmail(email)

        self.printUserInfo(avatar)

        if console.yesno("Are you sure to create and grant administrator privileges to this user?"):
            avatar.activateAccount()
            loginInfo = LoginInfo(login, password)
            authMgr = AuthenticatorMgr()
            userid = authMgr.createIdentity(loginInfo, avatar, "Local")
            authMgr.add(userid)
            adminList = info.HelperMaKaCInfo.getMaKaCInfoInstance().getAdminList()
            AvatarHolder().add(avatar)
            adminList.grant(avatar)
            print "New administrator created successfully with id: %s" % avatar.getId()
开发者ID:ferhatelmas,项目名称:indico,代码行数:33,代码来源:admin.py

示例2: user_create

# 需要导入模块: from MaKaC.user import Avatar [as 别名]
# 或者: from MaKaC.user.Avatar import getId [as 别名]
def user_create(grant_admin):
    """Creates new user"""
    avatar = Avatar()
    user_type = 'user' if not grant_admin else 'admin'

    print()
    name = prompt("First name")
    surname = prompt("Last name")
    organization = prompt("Affiliation")
    print()
    login = prompt("Enter username")
    email = prompt_email().encode('utf-8')
    if email is None:
        return
    password = prompt_pass().encode('utf-8')
    if password is None:
        return

    avatar.setName(name)
    avatar.setSurName(surname)
    avatar.setOrganisation(organization)
    avatar.setLang("en_GB")
    avatar.setEmail(email)
    print_user_info(avatar)

    if prompt_bool(cformat("%{yellow}Create the new {}?").format(user_type), default=True):
        from MaKaC.authentication import AuthenticatorMgr
        avatar.activateAccount()
        login_info = LoginInfo(login, password)
        auth_mgr = AuthenticatorMgr()
        try:
            user_id = auth_mgr.createIdentity(login_info, avatar, "Local")
            auth_mgr.add(user_id)
            AvatarHolder().add(avatar)
            if grant_admin:
                admin_list = HelperMaKaCInfo.getMaKaCInfoInstance().getAdminList()
                admin_list.grant(avatar)
            success("New {} created successfully with ID: {}".format(user_type, avatar.getId()))
        except UserError as e:
            error("Error: {}".format(str(e)))
开发者ID:pferreir,项目名称:indico-backup,代码行数:42,代码来源:admin.py

示例3: TestTasks

# 需要导入模块: from MaKaC.user import Avatar [as 别名]
# 或者: from MaKaC.user.Avatar import getId [as 别名]
class TestTasks(IndicoTestCase):
    """ Tests outlook plugin tasks operations
    """

    _requires = ['db.Database', 'db.DummyUser']

    def setUp(self):
        super(TestTasks, self).setUp()
        self._startDBReq()

        PluginsHolder().updateAllPluginInfo()
        PluginsHolder().getPluginType('calendaring').setActive(True)
        PluginsHolder().getPluginType('calendaring').getPlugin('outlook').setActive(True)

        # Create two dummy users
        ah = AvatarHolder()
        self._avatar1 = Avatar()
        self._avatar1.setName("fake-1")
        self._avatar1.setSurName("fake1")
        self._avatar1.setOrganisation("fake1")
        self._avatar1.setEmail("[email protected]")
        ah.add(self._avatar1)
        self._avatar2 = Avatar()
        self._avatar2.setName("fake-2")
        self._avatar2.setSurName("fake2")
        self._avatar2.setOrganisation("fake2")
        self._avatar2.setEmail("[email protected]")
        ah.add(self._avatar2)

        # Create two dummy conferences
        category = conf.CategoryManager().getById('0')
        ch = ConferenceHolder()

        self._conf1 = category.newConference(self._avatar1)
        self._conf1.setTimezone('UTC')
        sd1 = datetime(2012, 12, 1, 10, 0, tzinfo=timezone('UTC'))
        ed1 = datetime(2012, 12, 1, 18, 0, tzinfo=timezone('UTC'))
        self._conf1.setDates(sd1, ed1)
        ch.add(self._conf1)

        self._conf2 = category.newConference(self._avatar2)
        self._conf2.setTimezone('UTC')
        sd2 = datetime(2012, 12, 10, 11, 0, tzinfo=timezone('UTC'))
        ed2 = datetime(2012, 12, 11, 13, 0, tzinfo=timezone('UTC'))
        self._conf2.setDates(sd2, ed2)
        ch.add(self._conf2)

        self._stopDBReq()

    def tearDown( self ):
        super(TestTasks, self).tearDown()
        ContextManager.destroy()

    @with_context('database')
    def testOutlookRunTask(self):
        """ Tests outlook notification scheduler task.
            Using mock to avoid running real POST requests.
        """

        mockReturn = []

        def mock_sendEventRequest(self, key, eventType, avatar, conference):
            if avatar.getName() == 'fake-2' and conference.getId() == '0':
                mockReturn.append(200)
                return 200
            if avatar.getName() == 'fake-2' and conference.getId() == '1' and eventType == "added":
                mockReturn.append(200)
                return 200
            mockReturn.append(None)
            return None

        OutlookUpdateCalendarNotificationTask._sendEventRequest = mock_sendEventRequest
        outlookTask = OutlookUpdateCalendarNotificationTask(MINUTELY)

        storage = getAvatarConferenceStorage()

        addAvatarConference(self._avatar1, self._conf1, "added")
        addAvatarConference(self._avatar1, self._conf1, "removed")
        addAvatarConference(self._avatar2, self._conf2, "added")
        outlookTask.run()
        self.assertEqual(mockReturn, [None, 200])
        self.assertEqual(len(storage), 1)
        self.assertEqual(len(storage[self._avatar1.getId() + '_' + self._conf1.getId()]), 2)
        mockReturn = []

        addAvatarConference(self._avatar1, self._conf2, "added")
        addAvatarConference(self._avatar1, self._conf2, "removed")
        outlookTask.run()
        self.assertEqual(mockReturn, [None])
        self.assertEqual(len(storage), 2)
        self.assertEqual(len(storage[self._avatar1.getId() + '_' + self._conf1.getId()]), 2)
        self.assertEqual(len(storage[self._avatar1.getId() + '_' + self._conf2.getId()]), 2)
        mockReturn = []

        outlookTask._clearAvatarConferenceStorage([self._avatar1.getId() + '_' + self._conf2.getId()])
        outlookTask._clearAvatarConferenceStorage([self._avatar1.getId() + '_' + self._conf1.getId()])
        self.assertEqual(len(storage), 0)
开发者ID:VishrutMehta,项目名称:indico,代码行数:99,代码来源:tasks_tests.py

示例4: TestStorage

# 需要导入模块: from MaKaC.user import Avatar [as 别名]
# 或者: from MaKaC.user.Avatar import getId [as 别名]
class TestStorage(IndicoTestCase):
    """ Tests plugin storage management
    """

    _requires = ['db.Database', 'db.DummyUser']

    def setUp(self):
        super(TestStorage, self).setUp()
        self._startDBReq()

        PluginsHolder().updateAllPluginInfo()
        PluginsHolder().getPluginType('calendaring').setActive(True)
        PluginsHolder().getPluginType('calendaring').getPlugin('outlook').setActive(True)

        # Create two dummy users
        ah = AvatarHolder()
        self._avatar1 = Avatar()
        self._avatar1.setName("fake-3")
        self._avatar1.setSurName("fake3")
        self._avatar1.setOrganisation("fake3")
        self._avatar1.setEmail("[email protected]")
        ah.add(self._avatar1)
        self._avatar2 = Avatar()
        self._avatar2.setName("fake-4")
        self._avatar2.setSurName("fake4")
        self._avatar2.setOrganisation("fake4")
        self._avatar2.setEmail("[email protected]")
        ah.add(self._avatar2)

        # Create two dummy conferences
        category = conf.CategoryManager().getById('0')
        ch = ConferenceHolder()

        self._conf1 = category.newConference(self._avatar1)
        self._conf1.setTimezone('UTC')
        sd1 = datetime(2020, 12, 1, 10, 0, tzinfo=timezone('UTC'))
        ed1 = datetime(2020, 12, 1, 18, 0, tzinfo=timezone('UTC'))
        self._conf1.setDates(sd1, ed1)
        ch.add(self._conf1)

        self._conf2 = category.newConference(self._avatar2)
        self._conf2.setTimezone('UTC')
        sd2 = datetime(2020, 12, 10, 11, 0, tzinfo=timezone('UTC'))
        ed2 = datetime(2020, 12, 11, 13, 0, tzinfo=timezone('UTC'))
        self._conf2.setDates(sd2, ed2)
        ch.add(self._conf2)

        self._stopDBReq()

    @with_context('database')
    def testAddStorageElements(self):
        """ Tests adding elements to the storage
        """
        storage = getAvatarConferenceStorage()
        self.assertEqual(len(storage), 0)

        addAvatarConference(self._avatar1, self._conf1, "added")
        self.assertEqual(len(storage), 1)
        self.assertEqual(len(storage[self._avatar1.getId() + '_' + self._conf1.getId()]), 1)
        self.assertEqual(storage[self._avatar1.getId() + '_' + self._conf1.getId()][0]["eventType"], "added")

        addAvatarConference(self._avatar1, self._conf1, "removed")
        self.assertEqual(len(storage), 1)
        self.assertEqual(len(storage[self._avatar1.getId() + '_' + self._conf1.getId()]), 2)
        self.assertEqual(storage[self._avatar1.getId() + '_' + self._conf1.getId()][1]["eventType"], "removed")

        addAvatarConference(self._avatar1, self._conf2, "added")
        self.assertEqual(len(storage), 2)
        self.assertEqual(len(storage[self._avatar1.getId() + '_' + self._conf2.getId()]), 1)
        self.assertEqual(len(storage[self._avatar1.getId() + '_' + self._conf1.getId()]), 2)
        self.assertEqual(storage[self._avatar1.getId() + '_' + self._conf2.getId()][0]["eventType"], "added")

        addAvatarConference(self._avatar2, self._conf1, "added")
        self.assertEqual(len(storage), 3)
        self.assertEqual(len(storage[self._avatar2.getId() + '_' + self._conf1.getId()]), 1)
        self.assertEqual(storage[self._avatar2.getId() + '_' + self._conf1.getId()][0]["eventType"], "added")

        addAvatarConference(self._avatar2, self._conf2, "added")
        self.assertEqual(len(storage), 4)
        self.assertEqual(len(storage[self._avatar2.getId() + '_' + self._conf2.getId()]), 1)
        self.assertEqual(storage[self._avatar2.getId() + '_' + self._conf2.getId()][0]["eventType"], "added")

        addAvatarConference(self._avatar2, self._conf2, "removed")
        self.assertEqual(len(storage), 4)
        self.assertEqual(len(storage[self._avatar2.getId() + '_' + self._conf2.getId()]), 2)
        self.assertEqual(storage[self._avatar2.getId() + '_' + self._conf2.getId()][1]["eventType"], "removed")

        addAvatarConference(self._avatar1, self._conf1, "added")
        addAvatarConference(self._avatar1, self._conf1, "removed")

        self.assertEqual(len(storage), 4)
        self.assertEqual(len(storage[self._avatar1.getId() + '_' + self._conf1.getId()]), 2)

    @with_context('database')
    def testUpdateConference(self):
        """ Tests if update works properly after making changes in the conference
        """
        storage = getAvatarConferenceStorage()

        participant1 = Participant(self._conf1, self._avatar1)
#.........这里部分代码省略.........
开发者ID:ferhatelmas,项目名称:indico,代码行数:103,代码来源:storage_tests.py


注:本文中的MaKaC.user.Avatar.getId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。