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


Python C3sMember.get_by_code方法代码示例

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


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

示例1: search_codes

# 需要导入模块: from c3smembership.data.model.base.c3smember import C3sMember [as 别名]
# 或者: from c3smembership.data.model.base.c3smember.C3sMember import get_by_code [as 别名]
def search_codes(request):
    '''
    Search for Reference Codes

    We use a form with autocomplete to let staff find entries faster.
    '''
    # check for input from "find people" form
    if 'code_to_show' in request.POST:
        try:
            _code = request.POST['code_to_show']
            # print u"_code = {}".format(_code)
            _code_ = _code.split(' ')[0]
            # print u"_code_ = {}".format(_code_)
            _entry = C3sMember.get_by_code(_code_)
            # print _entry

            return HTTPFound(
                location=request.route_url(
                    'detail',
                    member_id=_entry.id)
            )
        except:
            pass

    '''
    we use another form with autocomplete to let staff find entries faster
    '''
    class AutocompleteRefCodeForm(colander.MappingSchema):
        code_to_show = colander.SchemaNode(
            colander.String(),
            title='Code finden (quicksearch; Groß-/Kleinschreibung beachten!)',
            widget=deform.widget.AutocompleteInputWidget(
                min_length=1,
                css_class="form-inline",
                values=request.route_path(
                    'autocomplete_input_values',
                    traverse=('autocomplete_input_values')
                )
            )
        )

    schema = AutocompleteRefCodeForm()
    form = deform.Form(
        schema,
        css_class="form-inline",
        buttons=('go!',),
    )
    refcodeformhtml = form.render()

    return {
        'refcodeform': refcodeformhtml,
    }
开发者ID:C3S,项目名称:c3sMembership,代码行数:54,代码来源:search.py

示例2: search_people

# 需要导入模块: from c3smembership.data.model.base.c3smember import C3sMember [as 别名]
# 或者: from c3smembership.data.model.base.c3smember.C3sMember import get_by_code [as 别名]
def search_people(request):
    '''
    Search for people.

    We use a form with autocomplete to let staff find entries faster.
    '''
    # check for input from "find people" form
    if 'code_to_show' in request.POST:
        try:
            _code = request.POST['code_to_show']
            # print u"_code = {}".format(_code)
            _code_ = _code.split(' ')[0]
            # print u"_code_ = {}".format(_code_)
            _entry = C3sMember.get_by_code(_code_)

            return HTTPFound(
                location=request.route_url(
                    'detail',
                    member_id=_entry.id)
            )
        except:
            pass

    class AutocompleteForm(colander.MappingSchema):
        code_to_show = colander.SchemaNode(
            colander.String(),
            title='Personen finden (Nachname: Groß-/Kleinschr. beachten!)',
            widget=deform.widget.AutocompleteInputWidget(
                min_length=1,
                css_class="form-inline",
                values=request.route_path(
                    'autocomplete_people_search',
                    traverse=('autocomplete_people_search')
                )
            )
        )

    schema = AutocompleteForm()
    form = deform.Form(
        schema,
        css_class="form-inline",
        buttons=('go!',),
    )
    autoformhtml = form.render()

    return {
        'autoform': autoformhtml,
    }
开发者ID:C3S,项目名称:c3sMembership,代码行数:50,代码来源:search.py

示例3: regenerate_pdf

# 需要导入模块: from c3smembership.data.model.base.c3smember import C3sMember [as 别名]
# 或者: from c3smembership.data.model.base.c3smember.C3sMember import get_by_code [as 别名]
def regenerate_pdf(request):
    """
    Staffers can regenerate an applicants PDF and send it to her.
    """
    code = request.matchdict['code']
    member = C3sMember.get_by_code(code)

    if member is None:
        request.session.flash(
            'A member with code {} does not exist'.format(code),
            'danger')
        return get_dashboard_redirect(request)

    membership_application = request.registry.membership_application.get(
        member.id)

    appstruct = {
        'firstname': member.firstname,
        'lastname': member.lastname,
        'address1': member.address1,
        'address2': member.address2,
        'postcode': member.postcode,
        'city': member.city,
        'email': member.email,
        'email_confirm_code': membership_application['payment_token'],
        'country': member.country,
        'locale': member.locale,
        'membership_type': membership_application['membership_type'],
        'num_shares': membership_application['shares_quantity'],
        'date_of_birth': member.date_of_birth,
        'date_of_submission': membership_application['date_of_submission'],
    }
    LOG.info(
        "%s regenerated the PDF for code %s",
        authenticated_userid(request),
        code)
    return generate_pdf(request, appstruct)
开发者ID:C3S,项目名称:c3sMembership,代码行数:39,代码来源:membership_acquisition.py

示例4: success_verify_email

# 需要导入模块: from c3smembership.data.model.base.c3smember import C3sMember [as 别名]
# 或者: from c3smembership.data.model.base.c3smember.C3sMember import get_by_code [as 别名]
def success_verify_email(request):
    """
    This view is called via links sent in mails to verify mail addresses.
    It extracts both email and verification code from the URL.
    It will ask for a password
    and checks if there is a match in the database.

    If the password matches, and all is correct,
    the view shows a download link and further info.
    """
    user_email = request.matchdict['email']
    confirm_code = request.matchdict['code']
    # if we want to ask the user for her password (through a form)
    # we need to have a url to send the form to
    post_url = '/verify/' + user_email + '/' + confirm_code

    if 'submit' in request.POST:
        request.session.pop_flash('message_above_form')
        request.session.pop_flash('message_above_login')
        if 'password' in request.POST:
            _passwd = request.POST['password']

        # get matching dataset from DB
        member = C3sMember.get_by_code(confirm_code)

        if isinstance(member, NoneType):
            not_found_msg = _(
                u"Not found. Check verification URL. "
                "If all seems right, please use the form again.")
            return {
                'correct': False,
                'namepart': '',
                'result_msg': not_found_msg,
            }

        # check if the password is valid
        try:
            correct = C3sMember.check_password(member.id, _passwd)
        except AttributeError:
            correct = False
            request.session.flash(
                _(u'Wrong Password!'),
                'message_above_login')

        if (member.email == user_email) and correct:
            # set the email_is_confirmed flag in the DB for this signee
            member.email_is_confirmed = True
            namepart = member.firstname + member.lastname

            # Replace special characters with underscore
            import re
            pdf_file_name_part = re.sub(
                '[^a-zA-Z0-9]',
                '_',
                namepart)

            appstruct = {
                'firstname': member.firstname,
                'lastname': member.lastname,
                'email': member.email,
                'email_confirm_code': member.email_confirm_code,
                'address1': member.address1,
                'address2': member.address2,
                'postcode': member.postcode,
                'city': member.city,
                'country': member.country,
                'date_of_birth': member.date_of_birth,
                'date_of_submission': member.date_of_submission,
                'membership_type': member.membership_type,
                'member_of_colsoc':
                    u'yes' if member.member_of_colsoc else u'no',
                'name_of_colsoc': member.name_of_colsoc,
                'num_shares': member.num_shares,
            }
            request.session['appstruct'] = appstruct

            # log this person in, using the session
            LOG.info('verified code and password for id %s', member.id)
            request.session.save()
            return {
                'firstname': member.firstname,
                'lastname': member.lastname,
                'code': member.email_confirm_code,
                'correct': True,
                'namepart': pdf_file_name_part,
                'result_msg': _("Success. Load your PDF!")
            }
    request.session.flash(
        _(u"Please enter your password."),
        'message_above_login',
        allow_duplicate=False
    )
    return {
        'post_url': post_url,
        'firstname': '',
        'lastname': '',
        'namepart': '',
        'correct': False,
        'result_msg': "something went wrong."
    }
开发者ID:C3S,项目名称:c3sMembership,代码行数:102,代码来源:join.py


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