本文整理汇总了Python中MaKaC.user.Avatar.setName方法的典型用法代码示例。如果您正苦于以下问题:Python Avatar.setName方法的具体用法?Python Avatar.setName怎么用?Python Avatar.setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MaKaC.user.Avatar
的用法示例。
在下文中一共展示了Avatar.setName方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _run
# 需要导入模块: from MaKaC.user import Avatar [as 别名]
# 或者: from MaKaC.user.Avatar import setName [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()
示例2: setUp
# 需要导入模块: from MaKaC.user import Avatar [as 别名]
# 或者: from MaKaC.user.Avatar import setName [as 别名]
def setUp(self):
super(TestAuthentication, self).setUp()
with self._context("database"):
# Create few users and groups
gh = GroupHolder()
ah = AvatarHolder()
self._authMgr = AuthenticatorMgr()
for i in xrange(1, 3):
group = Group()
group.setName("fake-group-%d" % i)
group.setDescription("fake")
group.setEmail("fake-group-%[email protected]" % i)
group.setId("fake-group-%d" % i)
avatar = Avatar()
avatar.setName("fake-%d" % i)
avatar.setSurName("fake")
avatar.setOrganisation("fake")
avatar.setLang("en_GB")
avatar.setEmail("fake%[email protected]" % i)
avatar.setId("fake-%d" % i)
avatar.activateAccount()
group.addMember(avatar)
ah.add(avatar)
gh.add(group)
identity = self._authMgr.createIdentity(LoginInfo("fake-%d" % i, "fake-%d" % i), avatar, "Local")
self._authMgr.add(identity)
示例3: setUp
# 需要导入模块: from MaKaC.user import Avatar [as 别名]
# 或者: from MaKaC.user.Avatar import setName [as 别名]
def setUp(self):
super(TestAbstractSubmission, self).setUp()
self._startDBReq()
# Create few users
ah = AvatarHolder()
# Create dummy avatars in obj._avatarN
self._avatars = []
for i in xrange(1, 5):
avatar = Avatar()
avatar.setName("fake-%d" % i)
avatar.setSurName("fake")
avatar.setOrganisation("fake")
avatar.setLang("en_GB")
avatar.setEmail("fake%[email protected]" % i)
avatar.setId("fake-%d" % i)
ah.add(avatar)
self._avatars.append(avatar)
setattr(self, '_avatar%d' % i, avatar)
# Create a conference
category = conference.CategoryManager().getById('0')
self._conf = category.newConference(self._avatar1)
self._conf.setTimezone('UTC')
sd = datetime(2011, 11, 1, 10, 0, tzinfo=timezone('UTC'))
ed = datetime(2011, 11, 1, 18, 0, tzinfo=timezone('UTC'))
self._conf.setDates(sd, ed)
ch = ConferenceHolder()
ch.add(self._conf)
self._stopDBReq()
示例4: create_dummy_user
# 需要导入模块: from MaKaC.user import Avatar [as 别名]
# 或者: from MaKaC.user.Avatar import setName [as 别名]
def create_dummy_user():
"""
Creates a dummy user for testing purposes
"""
avatar = Avatar()
avatar.setName("fake")
avatar.setSurName("fake")
avatar.setOrganisation("fake")
avatar.setLang("en_GB")
avatar.setEmail("[email protected]")
# registering user
ah = AvatarHolder()
ah.add(avatar)
# setting up the login info
li = LoginInfo("dummyuser", "dummyuser")
ih = AuthenticatorMgr()
userid = ih.createIdentity(li, avatar, "Local")
ih.add(userid)
# activate the account
avatar.activateAccount()
# since the DB is empty, we have to add dummy user as admin
minfo = HelperMaKaCInfo.getMaKaCInfoInstance()
al = minfo.getAdminList()
al.grant(avatar)
dc = DefaultConference()
HelperMaKaCInfo.getMaKaCInfoInstance().setDefaultConference(dc)
return avatar
示例5: setUp
# 需要导入模块: from MaKaC.user import Avatar [as 别名]
# 或者: from MaKaC.user.Avatar import setName [as 别名]
def setUp(self):
super(TestAbstractJudgements, self).setUp()
self._startDBReq()
# Get dummy user and create another one
ah = AvatarHolder()
avatar1 = ah.getById(0)
avatar2 = Avatar()
avatar2.setName("fake-2")
avatar2.setSurName("fake")
avatar2.setOrganisation("fake")
avatar2.setLang("en_GB")
avatar2.setEmail("[email protected]")
avatar2.setId("fake-2")
ah.add(avatar2)
setattr(self, '_avatar1', avatar1)
setattr(self, '_avatar2', avatar2)
# Create a conference
category = conference.CategoryManager().getById('0')
self._conf = category.newConference(self._avatar1)
self._conf.setTimezone('UTC')
sd = datetime(2011, 11, 1, 10, 0, tzinfo=timezone('UTC'))
ed = datetime(2011, 11, 1, 18, 0, tzinfo=timezone('UTC'))
self._conf.setDates(sd, ed)
ch = ConferenceHolder()
ch.add(self._conf)
self._ctOral = conference.ContributionType("oral", "", self._conf)
self._conf.addContribType(self._ctOral)
self._track1 = self._conf.newTrack()
self._track2 = self._conf.newTrack()
self._track3 = self._conf.newTrack()
self._abstract1 = self._conf.getAbstractMgr().newAbstract(self._avatar1)
self._abstract2 = self._conf.getAbstractMgr().newAbstract(self._avatar1)
self._abstract3 = self._conf.getAbstractMgr().newAbstract(self._avatar1)
self._abstract4 = self._conf.getAbstractMgr().newAbstract(self._avatar1)
self._abstract5 = self._conf.getAbstractMgr().newAbstract(self._avatar1)
self._abstract1.setTracks([self._track1, self._track2, self._track3])
self._abstract2.setTracks([self._track1, self._track2])
self._abstract3.setTracks([self._track1])
self._abstract4.setTracks([self._track2, self._track3])
self._abstract5.setTracks([self._track3])
self._stopDBReq()
示例6: create_user
# 需要导入模块: from MaKaC.user import Avatar [as 别名]
# 或者: from MaKaC.user.Avatar import setName [as 别名]
def create_user(name, login, authManager):
avatar = Avatar()
avatar.setName(name)
avatar.setSurName(name)
avatar.setOrganisation("fake")
avatar.setLang("en_GB")
avatar.setEmail("%[email protected]" % name)
# setting up the login info
li = LoginInfo(login, login)
userid = authManager.createIdentity(li, avatar, "Local")
authManager.add(userid)
# activate the account
avatar.activateAccount()
return avatar
示例7: user_create
# 需要导入模块: from MaKaC.user import Avatar [as 别名]
# 或者: from MaKaC.user.Avatar import setName [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)))
示例8: start
# 需要导入模块: from MaKaC.user import Avatar [as 别名]
# 或者: from MaKaC.user.Avatar import setName [as 别名]
def start(self, obj):
super(RoomBooking_Feature, self).start(obj)
with obj._context('database'):
# Tell indico to use the current database for roombooking stuff
minfo = HelperMaKaCInfo.getMaKaCInfoInstance()
cfg = Configuration.Config.getInstance()
minfo.setRoomBookingDBConnectionParams(cfg.getDBConnectionParams())
obj._ph.getById('RoomBooking').setActive(True)
DALManagerCERN.connect()
initializeRoomBookingDB("Universe", force=False)
DALManagerCERN.disconnect()
# do not use the method for it as it tries to re-create jsvars and fails
minfo._roomBookingModuleActive = True
DALManagerCERN.connect()
# Create dummy avatars in obj._avatarN
ah = AvatarHolder()
obj._avatars = []
for i in xrange(1, 5):
avatar = Avatar()
avatar.setName("fake-%d" % i)
avatar.setSurName("fake")
avatar.setOrganisation("fake")
avatar.setLang("en_GB")
avatar.setEmail("fake%[email protected]" % i)
avatar.setId("rb-fake-%d" % i)
# setting up the login info
li = LoginInfo("fake-%d" % i, "fake-%d" % i)
ih = AuthenticatorMgr()
userid = ih.createIdentity(li, avatar, "Local")
ih.add(userid)
# activate the account
avatar.activateAccount()
ah.add(avatar)
obj._avatars.append(avatar)
setattr(obj, '_avatar%d' % i, avatar)
# Create dummy rooms in obj._roomN - owners are fake1 and fake2 (r1 has f1, r2 has f2, r3 has f1, ...)
location = Location.getDefaultLocation()
obj._rooms = []
for i in xrange(1, 8):
room = location.newRoom()
room.locationName = location.friendlyName
room.name = 'DummyRoom%d' % i
room.site = 'a'
room.building = 1
room.floor = 'b'
room.roomNr = 'c'
room.latitude = ''
room.longitude = ''
room.isActive = True
room.isReservable = True
room.resvsNeedConfirmation = False
room.responsibleId = 'rb-fake-%d' % (((i - 1) % 2) + 1)
room.whereIsKey = 'Nowhere'
room.telephone = '123456789'
room.capacity = 10
room.division = ''
room.surfaceArea = 50
room.comments = ''
room.setEquipment([])
room.setAvailableVC([])
room.insert()
obj._rooms.append(room)
setattr(obj, '_room%d' % i, room)
示例9: TestProtection
# 需要导入模块: from MaKaC.user import Avatar [as 别名]
# 或者: from MaKaC.user.Avatar import setName [as 别名]
class TestProtection(IndicoTestCase):
_requires = ['db.Database', 'db.DummyUser']
def setUp(self):
super(TestProtection, self).setUp()
self._startDBReq()
# Create a user
ah = AvatarHolder()
self._avatar = Avatar()
self._avatar.setName("fake")
self._avatar.setSurName("fake")
self._avatar.setOrganisation("fake")
self._avatar.setLang("en_GB")
self._avatar.setEmail("[email protected]")
self._avatar.setId("fake")
ah.add(self._avatar)
# Create a conference
category = conference.CategoryManager().getById('0')
self._conf = category.newConference(self._avatar)
self._conf.setTimezone('UTC')
sd = datetime(2011, 11, 1, 10, 0, tzinfo=timezone('UTC'))
ed = datetime(2011, 11, 1, 18, 0, tzinfo=timezone('UTC'))
self._conf.setDates(sd, ed)
ch = ConferenceHolder()
ch.add(self._conf)
self._contrib1 = conference.Contribution()
self._conf.addContribution(self._contrib1)
self._session1 = conference.Session()
self._conf.addSession(self._session1)
self._session2 = conference.Session()
self._conf.addSession(self._session2)
self._contrib2 = conference.Contribution()
self._session1.addContribution(self._contrib2)
#Now we create the material (id=0) and attach it to the contrib
self._material = conference.Material()
self._contrib1.addMaterial( self._material )
#Now we create a dummy file and attach it to the material
filePath = os.path.join( os.getcwd(), "test.txt" )
fh = open(filePath, "w")
fh.write("hola")
fh.close()
self._resource = conference.LocalFile()
self._resource.setFilePath( filePath )
self._resource.setFileName( "test.txt" )
self._material.addResource( self._resource )
self._stopDBReq()
@with_context('database')
def testOnlyPublic(self):
self.assertEqual(self._conf.getAccessController().isFullyPublic(), True)
self.assertEqual(self._contrib1.getAccessController().isFullyPublic(), True)
self.assertEqual(self._contrib2.getAccessController().isFullyPublic(), True)
self.assertEqual(self._session1.getAccessController().isFullyPublic(), True)
self.assertEqual(self._session2.getAccessController().isFullyPublic(), True)
self.assertEqual(self._material.getAccessController().isFullyPublic(), True)
self.assertEqual(self._resource.getAccessController().isFullyPublic(), True)
@with_context('database')
def testOnlyPrivate(self):
self._conf.setProtection(1)
self._contrib1.setProtection(1)
self._contrib2.setProtection(1)
self._session1.setProtection(1)
self._session2.setProtection(1)
self._material.setProtection(1)
self._resource.setProtection(1)
self.assertEqual(self._conf.getAccessController().isFullyPrivate(), True)
self.assertEqual(self._contrib1.getAccessController().isFullyPrivate(), True)
self.assertEqual(self._contrib2.getAccessController().isFullyPrivate(), True)
self.assertEqual(self._session1.getAccessController().isFullyPrivate(), True)
self.assertEqual(self._session2.getAccessController().isFullyPrivate(), True)
self.assertEqual(self._material.getAccessController().isFullyPrivate(), True)
self.assertEqual(self._resource.getAccessController().isFullyPrivate(), True)
@with_context('database')
def testPrivateInPublic(self):
self._contrib2.setProtection(1)
self._session2.setProtection(1)
self._resource.setProtection(1)
self.assertEqual(self._session1.getAccessController().isFullyPublic(), False)
self.assertEqual(self._conf.getAccessController().isFullyPublic(), False)
self.assertEqual(self._session1.getAccessController().getProtectedChildren(), [self._contrib2])
self.assertEqual(self._contrib1.getAccessController().getProtectedChildren(), [self._resource])
self.assertEqual(self._material.getAccessController().getProtectedChildren(), [self._resource])
self.assertEqual(set(self._conf.getAccessController().getProtectedChildren()), set([self._contrib2, self._session2, self._resource]))
self._contrib1.removeMaterial(self._material)
#.........这里部分代码省略.........
示例10: TestTasks
# 需要导入模块: from MaKaC.user import Avatar [as 别名]
# 或者: from MaKaC.user.Avatar import setName [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)
示例11: TestStorage
# 需要导入模块: from MaKaC.user import Avatar [as 别名]
# 或者: from MaKaC.user.Avatar import setName [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)
#.........这里部分代码省略.........