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


Python models.C3sMember类代码示例

本文整理汇总了Python中c3smembership.models.C3sMember的典型用法代码示例。如果您正苦于以下问题:Python C3sMember类的具体用法?Python C3sMember怎么用?Python C3sMember使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_calculate_partial_dues15

    def test_calculate_partial_dues15(self):
        """
        A test to check if partial dues are calculated the right way.

        "Partial dues" means you have to pay for half a year only, for example.
        """
        from c3smembership.views.membership_dues import (
            calculate_partial_dues15)
        member = C3sMember.get_by_id(1)
        res = calculate_partial_dues15(member)
        # print res
        # print member.membership_date
        assert res == (u'q1_2015', D('50'))

        # english member
        member_en = C3sMember.get_by_id(2)
        res = calculate_partial_dues15(member_en)
        # print res
        assert res == (u'q1_2015', D('50'))

        member_en.membership_date = date(2015, 6, 1)
        res = calculate_partial_dues15(member_en)
        # print res
        assert res == (u'q2_2015', D('37.50'))

        member_en.membership_date = date(2015, 9, 1)
        res = calculate_partial_dues15(member_en)
        # print res
        assert res == (u'q3_2015', D('25'))

        member_en.membership_date = date(2015, 11, 1)
        res = calculate_partial_dues15(member_en)
        # print res
        assert res == (u'q4_2015', D('12.50'))
开发者ID:,项目名称:,代码行数:34,代码来源:

示例2: member_list_print_view

def member_list_print_view(request):
    """
    This view produces printable HTML output, i.e. HTML without links

    It was used before the PDF-generating view above existed
    """
    all_members = C3sMember.member_listing(
        'lastname', how_many=C3sMember.get_number(), offset=0, order=u'asc')
    member_list = []
    count = 0
    for member in all_members:
        if member.is_member():
            # check membership number
            try:
                assert(member.membership_number is not None)
            except AssertionError:
                if DEBUG:  # pragma: no cover
                    print u"failed at id {} lastname {}".format(
                        member.id, member.lastname)
            member_list.append(member)
            count += 1
    # sort members alphabetically
    import locale
    locale.setlocale(locale.LC_ALL, "de_DE.UTF-8")

    member_list.sort(key=lambda x: x.firstname, cmp=locale.strcoll)
    member_list.sort(key=lambda x: x.lastname, cmp=locale.strcoll)

    return {
        'members': member_list,
        'count': count,
        '_today': date.today(),
    }
开发者ID:,项目名称:,代码行数:33,代码来源:

示例3: delete_entry

def delete_entry(request):
    """
    This view lets accountants delete entries (doublettes)
    """
    memberid = request.matchdict["memberid"]
    dashboard_page = request.cookies["on_page"]
    _member = C3sMember.get_by_id(memberid)

    C3sMember.delete_by_id(_member.id)
    log.info("member.id %s was deleted by %s" % (_member.id, request.user.login))

    return HTTPFound(request.route_url("dashboard", number=dashboard_page))
开发者ID:hedgeburner,项目名称:c3sMembership,代码行数:12,代码来源:accountants_views.py

示例4: export_yes_emails

def export_yes_emails(request):
    """
    export the database to a CSV file
    """
    datasets = C3sMember.member_listing(
        "id", how_many=C3sMember.get_number(), order='asc')
    rows = []  # start with empty list
    for m in datasets:
        if m.signature_received and m.payment_received:
            rows.append(
                (m.firstname + ' ' + m.lastname + ' <' + m.email + '>',))
    return {
        'header': ['Vorname Nachname <[email protected]>', ],
        'rows': rows}
开发者ID:ebora,项目名称:c3sMembership,代码行数:14,代码来源:accountants_views.py

示例5: send_certificate_email

def send_certificate_email(request):
    """
    Send email to a member with a link
    so the member can get her membership certificate.
    """
    _special_condition = False  # for redirects to referrer

    mid = request.matchdict["id"]
    member = C3sMember.get_by_id(mid)
    if isinstance(member, NoneType) or not member.is_member():
        return Response("that id does not exist or is not an accepted member. go back", status="404 Not Found")
    # create a token for the certificate
    member.certificate_token = make_random_token()

    email_subject, email_body = make_membership_certificate_email(request, member)

    the_message = Message(subject=email_subject, sender="[email protected]", recipients=[member.email], body=email_body)
    send_message(request, the_message)

    member.certificate_email = True
    member.certificate_email_date = datetime.now()

    try:  # pragma: no cover
        if "detail" in request.referrer:
            _special_condition = True
    except TypeError:  # pragma: no cover
        pass

    if _special_condition:  # pragma: no cover
        return HTTPFound(location=request.referrer + "#certificate")
    else:
        return get_memberhip_listing_redirect(request, member.id)
开发者ID:C3S,项目名称:c3sMembership,代码行数:32,代码来源:membership_certificate.py

示例6: verify_mailaddress_conf

def verify_mailaddress_conf(request):
    '''
    let member confirm her email address by clicking a link
    '''
    user_email = request.matchdict['email']
    refcode = request.matchdict['refcode']
    token = request.matchdict['token']
    # try to get entry from DB
    afm = C3sMember.get_by_code(refcode)
    if isinstance(afm, NoneType):  # no entry?
        #print "entry not found"
        return {
            'confirmed': False,
            'firstname': 'foo',
            'lastname': 'bar',
            'result_msg': 'bad URL / bad codes. please contact [email protected]!',
        }
    # check token
    if ('_used' in afm.email_confirm_token):  # token was invalidated already
        #print "the token is empty"
        return {
            'confirmed': False,
            'firstname': afm.firstname,
            'lastname': afm.lastname,
            'result_msg': 'your token is invalid. please contact [email protected]!',
        }

    try:
        assert(afm.email_confirm_token in token)
        assert(token in afm.email_confirm_token)
        assert(afm.email in user_email)
        assert(user_email in afm.email)
    except:
        return {
            'confirmed': False,
            'firstname': 'foo',
            'lastname': 'bar',
            'result_msg': 'bad token/email. please contact [email protected]!',
        }

    afm.email_is_confirmed = True
    afm.email_confirm_token += u'_used'
    DBSession.flush()
    # notify staff
    message = Message(
        subject='[C3S Yes!] afm email confirmed',
        sender='[email protected]',
        recipients=[request.registry.settings['c3smembership.mailaddr'], ],
        body=u'see {}/detail/{}'.format(
            request.registry.settings['c3smembership.url'],
            afm.id)
    )
    mailer = get_mailer(request)
    mailer.send(message)
    return {
        'confirmed': True,
        'firstname': afm.firstname,
        'lastname': afm.lastname,
        'result_msg': u'',
    }
开发者ID:ebora,项目名称:c3sMembership,代码行数:60,代码来源:administration.py

示例7: regenerate_pdf

def regenerate_pdf(request):
    """
    staffers can regenerate a users pdf
    """
    _code = request.matchdict['code']
    _member = C3sMember.get_by_code(_code)

    if _member is None:  # that memberid did not produce good results
        return HTTPFound(  # back to base
            request.route_url('dashboard_only'))
    _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': _member.email_confirm_code,
        'country': _member.country,
        '_LOCALE_': _member.locale,
        'membership_type': _member.membership_type,
        'num_shares': _member.num_shares,
        'date_of_birth': _member.date_of_birth,
        'date_of_submission': _member.date_of_submission,
    }
    log.info(
        "%s regenerated the PDF for code %s" % (
            authenticated_userid(request), _code))
    return generate_pdf(_appstruct)
开发者ID:ebora,项目名称:c3sMembership,代码行数:30,代码来源:accountants_views.py

示例8: switch_pay

def switch_pay(request):
    """
    This view lets accountants switch member signature info
    has their signature arrived?
    """
    memberid = request.matchdict['memberid']
    dashboard_page = request.cookies['on_page']
    order = request.cookies['order']
    order_by = request.cookies['orderby']
    _member = C3sMember.get_by_id(memberid)

    if _member.payment_received is True:  # change to NOT SET
        _member.payment_received = False
        _member.payment_received_date = datetime(1970, 1, 1)
    elif _member.payment_received is False:  # set to NOW
        _member.payment_received = True
        _member.payment_received_date = datetime.now()

    log.info(
        "payment info of member.id %s changed by %s to %s" % (
            _member.id,
            request.user.login,
            _member.payment_received
        )
    )
    return HTTPFound(
        request.route_url('dashboard',
                          number=dashboard_page, order=order, orderby=order_by))
开发者ID:ebora,项目名称:c3sMembership,代码行数:28,代码来源:accountants_views.py

示例9: switch_sig

def switch_sig(request):
    """
    This view lets accountants switch member signature info
    has their signature arrived?
    """
    memberid = request.matchdict['memberid']
    #log.info("the id: %s" % memberid)

    # store the dashboard page the admin came from
    dashboard_page = request.cookies['on_page']
    order = request.cookies['order']
    order_by = request.cookies['orderby']

    _member = C3sMember.get_by_id(memberid)
    if _member.signature_received is True:
        _member.signature_received = False
        _member.signature_received_date = datetime(1970, 1, 1)
    elif _member.signature_received is False:
        _member.signature_received = True
        _member.signature_received_date = datetime.now()

    log.info(
        "signature status of member.id %s changed by %s to %s" % (
            _member.id,
            request.user.login,
            _member.signature_received
        )
    )

    return HTTPFound(
        request.route_url('dashboard',
                          number=dashboard_page, order=order, orderby=order_by))
开发者ID:ebora,项目名称:c3sMembership,代码行数:32,代码来源:accountants_views.py

示例10: mail_payment_reminder

def mail_payment_reminder(request):
    """
    send a mail to membership applicant
    reminding her about lack of signature
    """
    _id = request.matchdict['memberid']
    _member = C3sMember.get_by_id(_id)

    message = Message(
        subject=u"C3S: don't forget to pay your shares / Bitte Anteile bezahlen",
        sender='[email protected]',
        #bcc=[request.registry.settings['reminder_blindcopy']],
        recipients=[_member.email],
        body=make_payment_reminder_emailbody(_member)
    )
    mailer = get_mailer(request)
    mailer.send(message)
    try:  # if value is int
        _member.sent_payment_reminder += 1
    except:  # pragma: no cover
        # if value was None (after migration of DB schema)
        _member.sent_payment_reminder = 1
    _member.sent_payment_reminder_date = datetime.now()
    return HTTPFound(request.route_url(
        'dashboard',
        number=request.cookies['on_page'],
        order=request.cookies['order'],
        orderby=request.cookies['orderby']) + '#member_' + str(_member.id)
    )
开发者ID:ebora,项目名称:c3sMembership,代码行数:29,代码来源:accountants_views.py

示例11: mail_payment_confirmation

def mail_payment_confirmation(request):
    """
    send a mail to membership applicant
    informing her about reception of payment
    """
    _id = request.matchdict['memberid']
    _member = C3sMember.get_by_id(_id)

    if _member.locale == 'de':
        _subject = u'[C3S AFM] Wir haben Deine Zahlung erhalten. Dankeschön!'
    else:
        _subject = u'[C3S AFM] We have received your payment. Thanks!'

    message = Message(
        subject=_subject,
        sender='[email protected]',
        recipients=[_member.email],
        body=make_payment_confirmation_emailbody(_member)
    )
    #print(message.body)
    mailer = get_mailer(request)
    mailer.send(message)
    _member.payment_confirmed = True
    _member.payment_confirmed_date = datetime.now()
    return HTTPFound(request.route_url('dashboard',
                                       number=request.cookies['on_page'],
                                       order=request.cookies['order'],
                                       orderby=request.cookies['orderby'],
                                       )
                     )
开发者ID:ebora,项目名称:c3sMembership,代码行数:30,代码来源:accountants_views.py

示例12: delete_entry

def delete_entry(request):
    """
    This view lets accountants delete entries (doublettes)
    """
    memberid = request.matchdict['memberid']
    _member = C3sMember.get_by_id(memberid)

    C3sMember.delete_by_id(_member.id)
    log.info(
        "member.id %s was deleted by %s" % (
            _member.id,
            request.user.login,
        )
    )
    return HTTPFound(
        request.route_url('dashboard_only',  _query={'message': 'Member with id {0} was deleted.'.format(memberid)}))
开发者ID:krissik,项目名称:c3sMembership,代码行数:16,代码来源:accountants_views.py

示例13: dashboard

def dashboard(request):
    """
    The Dashboard.

    This view lets accountants view
    the **list of applications for membership**.

    Some details can be seen (name, email, link to more details)
    as well as their membership application *progress*:

    - has their signature arrived?
    - how about the payment?
    - have reminders been sent? receptions confirmed?

    There are also links to *edit* or *delete* one of the datasets.

    Once all requirements are fulfilled,
    an application can be turned into a membership from here:
    a button shows up.
    """

    pagination = request.pagination
    try:
        members = C3sMember.nonmember_listing(
            pagination.paging.content_offset,
            pagination.paging.page_size,
            pagination.sorting.sort_property,
            pagination.sorting.sort_direction)
    except (InvalidPropertyException, InvalidSortDirection):
        raise ParameterValidationException(
            'Page does not exist.',
            request.route_url(request.matched_route.name))
    return {
        'members': members,
    }
开发者ID:,项目名称:,代码行数:35,代码来源:

示例14: regenerate_pdf

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:
        return get_dashboard_redirect(request)
    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': member.email_confirm_code,
        'country': member.country,
        '_LOCALE_': member.locale,
        'membership_type': member.membership_type,
        'num_shares': member.num_shares,
        'date_of_birth': member.date_of_birth,
        'date_of_submission': member.date_of_submission,
    }
    LOG.info(
        "%s regenerated the PDF for code %s",
        authenticated_userid(request),
        code)
    return generate_pdf(appstruct)
开发者ID:,项目名称:,代码行数:30,代码来源:

示例15: test_shares_edit

    def test_shares_edit(self):
        '''
        tests for the shares_edit view
        '''
        # unauthorized access must be prevented
        res = self.testapp.reset()  # delete cookie
        res = self.testapp.get('/shares_edit/1', status=403)
        assert('Access was denied to this resource' in res.body)
        res = self.testapp.get('/login', status=200)
        self.failUnless('login' in res.body)
        # try valid user
        form = res.form
        form['login'] = u'rut'
        form['password'] = u'berries'
        res2 = form.submit('submit', status=302)
        # # being logged in ...
        res3 = res2.follow()  # being redirected to dashboard with parameters
        self.failUnless('Dashboard' in res3.body)

        # no member in DB, so redirecting to dashboard
        res = self.testapp.get('/shares_edit/1', status=302)
        res2 = res.follow()

        self.make_member_with_shares()

        # now there is a member with shares in the DB
        #
        # lets try invalid input
        res = self.testapp.get('/shares_edit/foo', status=302)
        res2 = res.follow()
        self.failUnless('Dashboard' in res2.body)

        # now try valid id
        res = self.testapp.get('/shares_edit/1', status=200)
        self.failUnless('Edit Details for Shares' in res.body)

        # now we change details, really editing that member
        form = res.form

        if DEBUG:
            print "form.fields: {}".format(form.fields)

        self.assertTrue('2' in form['number'].value)
        self.assertTrue(datetime.today().strftime(
            '%Y-%m-%d') in form['date_of_acquisition'].value)
        # print(form['date_of_acquisition'].value)
        form['number'] = u'3'
        form['date_of_acquisition'] = u'2015-01-02'

        # try to submit now. this must fail,
        # because the date of birth is wrong
        # ... and other dates are missing
        res2 = form.submit('submit', status=200)

        # check data in DB
        _m1 = C3sMember.get_by_id(1)
        self.assertTrue(_m1.shares[0].number is 3)
        self.assertTrue(str(
            _m1.shares[0].date_of_acquisition) in str(datetime(2015, 1, 2)))
开发者ID:,项目名称:,代码行数:59,代码来源:


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