本文整理汇总了Python中MaKaC.user.Avatar.setLang方法的典型用法代码示例。如果您正苦于以下问题:Python Avatar.setLang方法的具体用法?Python Avatar.setLang怎么用?Python Avatar.setLang使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MaKaC.user.Avatar
的用法示例。
在下文中一共展示了Avatar.setLang方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _run
# 需要导入模块: from MaKaC.user import Avatar [as 别名]
# 或者: from MaKaC.user.Avatar import setLang [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 setLang [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()
示例3: setUp
# 需要导入模块: from MaKaC.user import Avatar [as 别名]
# 或者: from MaKaC.user.Avatar import setLang [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)
示例4: create_dummy_user
# 需要导入模块: from MaKaC.user import Avatar [as 别名]
# 或者: from MaKaC.user.Avatar import setLang [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 setLang [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 setLang [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 setLang [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 setLang [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 setLang [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)
#.........这里部分代码省略.........