本文整理汇总了Python中MaKaC.user.Avatar.isRegisteredInConf方法的典型用法代码示例。如果您正苦于以下问题:Python Avatar.isRegisteredInConf方法的具体用法?Python Avatar.isRegisteredInConf怎么用?Python Avatar.isRegisteredInConf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MaKaC.user.Avatar
的用法示例。
在下文中一共展示了Avatar.isRegisteredInConf方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _import
# 需要导入模块: from MaKaC.user import Avatar [as 别名]
# 或者: from MaKaC.user.Avatar import isRegisteredInConf [as 别名]
def _import(self, file):
# check Registration period
import datetime
import pytz
utc = pytz.UTC
startDate = self._conf.getRegistrationForm().getStartRegistrationDate()
endDate = self._conf.getRegistrationForm().getEndRegistrationDate()
current = datetime.datetime.now()
current = utc.localize(current)
if (current < startDate or current > endDate):
raise NoReportError("Import registrants not authorized, outside registration period.")
reader = csv.DictReader(file)
i = 1
errors = []
successfuls = []
unsuccessfuls = []
for row in reader:
try:
# row['Email'] = row['Email'].lower()
self._processImportData(row)
matchedUsers = AvatarHolder().match({"email": row['Email']}, exact=1)
if matchedUsers:
user = matchedUsers[0]
elif ('Account Creation' in row) and row['Account Creation'].lower() == 'yes': # account creation
avData = self._mapAvatar(row)
user = Avatar(avData)
user.activateAccount()
login_info = LoginInfo(row['Login'], row['Password'])
auth_mgr = AuthenticatorMgr()
user_id = auth_mgr.createIdentity(login_info, user, "Local")
auth_mgr.add(user_id)
AvatarHolder().add(user)
else:
user = None
if not (user):
reg = Registrant() # new registration
self._conf.addRegistrant(reg, user)
else:
if user.isRegisteredInConf(self._conf):
reg = self._conf.getRegistrantsByEmail(user.getEmail())
else: # not registered, new registration
reg = Registrant()
reg.setAvatar(user)
self._conf.addRegistrant(reg, user)
user.addRegistrant(reg)
regData = self._mapRegistrant(row)
regData['import'] = 'import'
reg.setValues(regData, user)
self._setAffiliation(reg)
successfuls.append(reg.getFullName())
except Exception:
errors.append(i)
unsuccessfuls.append(
row["Surname"] + ", " + row["First Name"]) # exception : reg or user might not be defined yet
finally:
i += 1
self.logimport(successfuls, unsuccessfuls)
return errors