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


Python Avatar.isRegisteredInConf方法代码示例

本文整理汇总了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
开发者ID:cmorgia,项目名称:indicoaffiliation,代码行数:66,代码来源:fileimport.py


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