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


Python Member.update_index方法代码示例

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


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

示例1: post

# 需要导入模块: from model import Member [as 别名]
# 或者: from model.Member import update_index [as 别名]

#.........这里部分代码省略.........
        home = self.request.get('home')
        if home and home.strip() == '':
            home = None
        values['home'] = home

        work = self.request.get('work')
        if work and work.strip() == '':
            work = None
        values['work'] = work

        member_type = self.request.get('type')
        if not member_type or member_type.strip() == '':
            member_type = '1'

        types = MemberType.all().fetch(100)

        mtype = None

        # TODO: Custom settings? Constants at least.
        if member_type == '1':
            mtype = next(t for t in types if t.name == DEFAULT_MEMBER_NAME)
        else:
            mtype = next(t for t in types if t.name ==
                         DEFAULT_SUPPORT_MEMBER_NAME)

        values['type'] = mtype.name
        comment = self.request.get('comment')
        complete.append('comment')
        values['comment'] = comment

        error_message = ''

        # Check if member exists;
        existing = Member.all().filter('email', email).fetch(1)

        if len(existing) > 0:
            incomplete.append('email')
            error_message = 'Det er allerede registrert noen i medlemsregisteret med denne epostadressen!'
            # TODO: Error message

        if len(incomplete) > 0:
            # missing field, redirect to signup page again
            template = JINJA_ENVIRONMENT.get_template(
                'templates/selfservice/signup.html')
            return self.response.write(template.render({
                'countries': countries,
                'incomplete': incomplete,
                'complete': complete,
                'error_message': error_message,
                'values': values}))

        # invariant: fields are OK, create new member, send mail,
        # create payment history on member.
        template = JINJA_ENVIRONMENT.get_template(
            'templates/selfservice/signup_receipt.html')
        data = {
            'values': values,
            'profile_url': PROFILE_URL
        }

        statuses = Status.all().fetch(100)

        # TODO: Handle existing members signing up again

        new_member = Member()

        new_member.name = name
        new_member.address = address
        new_member.zipcode = zipcode
        new_member.city = city
        new_member.notes = comment
        new_member.country = country
        new_member.membertype = mtype

        status = next(s for s in statuses if s.name == SIGNUP_STATUS_NAME)
        new_member.status = status

        new_member.number = dbutils.create_new_member_no()

        new_member.email = email
        new_member.member_since = datetime.date.today()
        if mobile:
            new_member.phone = mobile
        if work:
            new_member.phone_work = work
        if home:
            new_member.phone_home = home
        new_member.generate_access_code()
        new_member.member_since = datetime.date.today()
        new_member.member_type = mtype
        new_member.put()
        new_member.update_index()

        self.send_welcome_mail(new_member)
        self.send_notification_mails(new_member)

        # TODO: Invalidate counts for categories
        # Handle mutations on members gracefully

        return self.response.write(template.render(data))
开发者ID:KlubbAlfaRomeoNorge,项目名称:members,代码行数:104,代码来源:signup.py


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