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


Python C3sMember.get_number方法代码示例

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


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

示例1: member_list_print_view

# 需要导入模块: from c3smembership.models import C3sMember [as 别名]
# 或者: from c3smembership.models.C3sMember import get_number [as 别名]
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:,项目名称:,代码行数:35,代码来源:

示例2: stats_view

# 需要导入模块: from c3smembership.models import C3sMember [as 别名]
# 或者: from c3smembership.models.C3sMember import get_number [as 别名]
def stats_view(request):
    """
    This view lets accountants view statistics:
    how many membership applications, real members, shares, etc.
    """
    # countries_dict = C3sMember.get_countries_list()
    _cl = C3sMember.get_countries_list()
    _cl_sorted = _cl.items()
    # print "die liste: {}".format(_cl_sorted)
    import operator
    _cl_sorted.sort(key=operator.itemgetter(1), reverse=True)
    # print "sortiert: {}".format(_cl_sorted)
    return {
        # form submissions
        '_number_of_datasets': C3sMember.get_number(),
        'afm_shares_unpaid': C3sMember.afm_num_shares_unpaid(),
        'afm_shares_paid': C3sMember.afm_num_shares_paid(),
        # shares
        # 'num_shares': C3sMember.get_total_shares(),
        'num_shares_members': Shares.get_total_shares(),
        # 'num_shares_mem_norm': Shares.get_sum_norm(),
        # 'num_shares_mem_inv': Shares.get_sum_inv(),

        # memberships
        'num_members_accepted': C3sMember.get_num_members_accepted(),
        'num_non_accepted': C3sMember.get_num_non_accepted(),
        'num_nonmember_listing': C3sMember.nonmember_listing_count(),
        'num_duplicates': len(C3sMember.get_duplicates()),
        # 'num_empty_slots': C3sMember.get_num_empty_slots(),
        # normal persons vs. legal entities
        'num_ms_nat_acc': C3sMember.get_num_mem_nat_acc(),
        'num_ms_jur_acc': C3sMember.get_num_mem_jur_acc(),
        # normal vs. investing memberships
        'num_ms_norm': C3sMember.get_num_mem_norm(),
        'num_ms_inves': C3sMember.get_num_mem_invest(),
        'num_ms_features': C3sMember.get_num_mem_other_features(),
        # membership_numbers
        'num_memnums': C3sMember.get_num_membership_numbers(),
        'max_memnum': C3sMember.get_highest_membership_number(),
        'next_memnum': C3sMember.get_next_free_membership_number(),

        # countries
        'num_countries': C3sMember.get_num_countries(),
        'countries_list': _cl_sorted,
        #    key=lambda x: x[1]
        # ),  # XXX TODO: sorte

        # dues stats
        'dues15_stats': Dues15Invoice.get_monthly_stats(),
        'dues16_stats': Dues16Invoice.get_monthly_stats(),

        # staff figures
        'num_staff': len(C3sStaff.get_all())
    }
开发者ID:,项目名称:,代码行数:56,代码来源:

示例3: export_yes_emails

# 需要导入模块: from c3smembership.models import C3sMember [as 别名]
# 或者: from c3smembership.models.C3sMember import get_number [as 别名]
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,代码行数:16,代码来源:accountants_views.py

示例4: export_yes_emails

# 需要导入模块: from c3smembership.models import C3sMember [as 别名]
# 或者: from c3smembership.models.C3sMember import get_number [as 别名]
def export_yes_emails(request):  # pragma: no cover
    """
    Export the members email addresses to a CSV file.

    XXX TODO: implement a test-case
    """
    datasets = C3sMember.member_listing(
        "id", how_many=C3sMember.get_number(), order='asc')
    rows = []  # start with empty list
    for member in datasets:
        if member.signature_received and member.payment_received:
            rows.append('{firstname} {lastname} <{email}>'.format(
                firstname=member.firstname,
                lastname=member.lastname,
                email=member.email))
    return {
        'header': ['Vorname Nachname <[email protected]>', ],
        'rows': rows}
开发者ID:,项目名称:,代码行数:20,代码来源:

示例5: stats_view

# 需要导入模块: from c3smembership.models import C3sMember [as 别名]
# 或者: from c3smembership.models.C3sMember import get_number [as 别名]
def stats_view(request):
    """
    This view lets accountants view statistics:
    how many membership applications, real members, shares, etc.
    """
    return {
        # form submissions
        '_number_of_datasets': C3sMember.get_number(),
        'afm_shares_unpaid': C3sMember.afm_num_shares_unpaid(),
        'afm_shares_paid': C3sMember.afm_num_shares_paid(),
        # shares
        #'num_shares': Shares.get_total_shares(),
        # memberships
        #'num_memberships': Membership.get_number(),
        #'num_ms_nat': Membership.get_number(),  # XXX check!
        #'num_ms_jur': '0',  # XXX Membership.num_ms_jur(),
        #'num_ms_norm': Membership.num_ms_norm(),
        #'num_ms_inves': Membership.num_ms_invest(),
        # staff figures
        'num_staff': len(C3sStaff.get_all())
    }
开发者ID:ebora,项目名称:c3sMembership,代码行数:23,代码来源:administration.py

示例6: export_db

# 需要导入模块: from c3smembership.models import C3sMember [as 别名]
# 或者: from c3smembership.models.C3sMember import get_number [as 别名]
def export_db(request):
    """
    export the database to a CSV file
    """
    datasets = C3sMember.member_listing(
        "id", how_many=C3sMember.get_number(), order='asc')
    header = ['firstname', 'lastname', 'email',
              'password', 'last_password_change',
              'address1', 'address2', 'postcode', 'city', 'country',
              'locale', 'date_of_birth',
              'email_is_confirmed', 'email_confirm_code',
              'num_shares', 'date_of_submission',
              'membership_type',
              'member_of_colsoc', 'name_of_colsoc',
              'signature_received', 'signature_received_date',
              'payment_received', 'payment_received_date',
              'signature_confirmed', 'signature_confirmed_date',
              'payment_confirmed', 'payment_confirmed_date',
              'accountant_comment',
              ]
    rows = []  # start with empty list
    for m in datasets:
        rows.append(
            (m.firstname, m.lastname, m.email,
             m.password, m.last_password_change,
             m.address1, m.address2, m.postcode, m.city, m.country,
             m.locale, m.date_of_birth,
             m.email_is_confirmed, m.email_confirm_code,
             m.num_shares, m.date_of_submission,
             m.membership_type,
             m.member_of_colsoc, m.name_of_colsoc,
             m.signature_received, m.signature_received_date,
             m.payment_received, m.payment_received_date,
             m.signature_confirmed, m.signature_confirmed_date,
             m.payment_confirmed, m.payment_confirmed_date,
             m.accountant_comment)
        )
    return {
        'header': header,
        'rows': rows}
开发者ID:ebora,项目名称:c3sMembership,代码行数:42,代码来源:accountants_views.py

示例7: accountants_desk

# 需要导入模块: from c3smembership.models import C3sMember [as 别名]
# 或者: from c3smembership.models.C3sMember import get_number [as 别名]
def accountants_desk(request):
    """
    This view lets accountants view applications and set their status:
    has their signature arrived? how about the payment?
    """
    #logged_in = authenticated_userid(request)
    #log.info("dashboard view..............................................")
    #print("---- authenticated_userid: " + str(logged_in))
    # this following stanza is overridden by the views permission settings
    #if logged_in is None:  # not authenticated???
    #    return HTTPFound(  # go back to login!!!
    #        location=route_url(
    #            'login',
    #            request=request),
    #    )

    _number_of_members = C3sMember.get_number()
    #print("We have %s members in this db." % _number_of_members)

    _members = C3sMember.member_listing(C3sMember.id.desc(), how_many=15)

    return {'_number_of_members': _number_of_members,
            'members': _members}
开发者ID:plamut,项目名称:c3sMembership,代码行数:25,代码来源:views.py

示例8: export_memberships

# 需要导入模块: from c3smembership.models import C3sMember [as 别名]
# 或者: from c3smembership.models.C3sMember import get_number [as 别名]
def export_memberships(request):  # pragma: no cover
    """
    Export the database to a CSV file.

    XXX TODO: implement a test-case
    """
    _num = C3sMember.get_number()
    datasets = C3sMember.get_members(
        'id', how_many=_num, offset=0, order=u'asc')
    header = [
        'firstname',
        'lastname',
        'email',
        'address1',
        'address2',
        'postcode',
        'city',
        'country',
        'locale',
        'date_of_birth',
        # 'email_is_confirmed',
        'email_confirm_code',
        'membership_date',
        'num_shares',
        # 'date_of_submission',
        # 'shares list (number+date)',
        'membership_type',
        'member_of_colsoc',
        'name_of_colsoc',
        'signature_received',
        'signature_received_date',
        'payment_received',
        'payment_received_date',
        # 'signature_confirmed',
        'signature_confirmed_date',
        # 'payment_confirmed',
        'payment_confirmed_date',
        'accountant_comment',
        'is_legalentity',
        'court of law',
        'registration number',]
    rows = []  # start with empty list
    for member in datasets:
        rows.append((
            member.firstname,
            member.lastname,
            member.email,
            member.address1,
            member.address2,
            member.postcode,
            member.city,
            member.country,
            member.locale,
            member.date_of_birth,
            # member.email_is_confirmed,
            member.email_confirm_code,
            member.membership_date,
            member.num_shares,
            # member.date_of_submission,
            # '+'.join(str(s.id)+'('+str(s.number)+')' for s in member.shares),
            member.membership_type,
            member.member_of_colsoc,
            member.name_of_colsoc,
            member.signature_received,
            member.signature_received_date,
            member.payment_received,
            member.payment_received_date,
            # member.signature_confirmed,
            member.signature_confirmed_date,
            # member.payment_confirmed,
            member.payment_confirmed_date,
            member.accountant_comment,
            member.is_legalentity,
            member.court_of_law,
            member.registration_number,))
    return {
        'header': header,
        'rows': rows}
开发者ID:,项目名称:,代码行数:80,代码来源:

示例9: test_switch_signature_and_payment

# 需要导入模块: from c3smembership.models import C3sMember [as 别名]
# 或者: from c3smembership.models.C3sMember import get_number [as 别名]
    def test_switch_signature_and_payment(self):
        # login
        res = self.testapp.get('/login', status=200)
        form = res.form
        form['login'] = 'rut'
        form['password'] = 'berries'
        res2 = form.submit('submit', status=302)
        # being logged in ...
        res3 = res2.follow()

        # have a set of headers with and without 'dashboard' in http referrer
        headers_dash = [
            ('Referer', 'http://this.app/dashboard')
        ]
        headers_nodash = [
            ('Referer', 'http://this.app/dashboard')
        ]

        # switch signature
        resD2a = self.testapp.get(
            '/switch_sig/1', status=302,
            headers=headers_dash)  # # # # # OFF
        resD2b = resD2a.follow()  # we are taken to the dashboard
        resD2b = self.testapp.get('/detail/1', status=200)
        # print resD2b.body
        self.assertTrue(
            "Eingang bestätigen" not in resD2b.body)
        resD2a = self.testapp.get(
            '/switch_sig/1', status=302,
            headers=headers_nodash
        )  # # # # # ON
        resD2b = resD2a.follow()  # we are taken to the dashboard
        resD2b = self.testapp.get('/detail/1', status=200)
        self.assertTrue(
            "Eingang bestätigen" in resD2b.body)
        #
        # switch payment
        resD3a = self.testapp.get(
            '/switch_pay/1', status=302,
            headers=headers_dash
        )  # # # # OFF
        resD3b = resD3a.follow()  # we are taken to the dashboard
        resD3b = self.testapp.get('/detail/1', status=200)
        self.assertTrue(
            "Zahlungseingang bestätigen" not in resD3b.body)
        resD3a = self.testapp.get('/switch_pay/1', status=302,
                                  headers=headers_dash)  # # # # ON
        resD3b = resD3a.follow()  # we are taken to the dashboard
        resD3b = self.testapp.get('/detail/1', status=200)
        self.assertTrue(
            "Zahlungseingang bestätigen" in resD3b.body)
        #
        ####################################################################
        # delete an entry
        _num = C3sMember.get_number()
        resDel2 = self.testapp.get(
            '/delete/1?deletion_confirmed=1', status=302)
        _num2 = C3sMember.get_number()
        self.assertTrue(int(_num2) + 1 == int(_num))
        resDel3 = resDel2.follow()
        self.failUnless('was deleted' in resDel3.body)

        # finally log out ##################################################
        res9 = self.testapp.get('/logout', status=302)  # redirects to login
        res10 = res9.follow()
        self.failUnless('login' in res10.body)
开发者ID:,项目名称:,代码行数:68,代码来源:

示例10: test_add_member

# 需要导入模块: from c3smembership.models import C3sMember [as 别名]
# 或者: from c3smembership.models.C3sMember import get_number [as 别名]

#.........这里部分代码省略.........
        form['city'] = u"Footown Meeh"
        form['country'].value__set(u"DE")
        form['_LOCALE_'] = u"DE"
        form['date_of_birth'] = date.today()
        # form['email_is_confirmed=False,
        # email_confirm_code=u'ABCDEFGFOO',
        # password=u'arandompassword',
        # date_of_submission=date.today(),
        form['entity_type'] = u'person'
        form['membership_type'] = u'normal'
        # form['deformField14'].value__set(u'normal')
        # form['other_colsoc'] = (u'no',),
        form['other_colsoc'].value__set(u'no')

        form['name_of_colsoc'] = u"GEMA"
        form['num_shares'] = u'23'

        # try to submit the form (knowing that the date is missing)
        res2 = form.submit(u'submit', status=200)
        form2 = res2.form
        form2['date_of_birth'] = u'1999-09-19'

        res3 = form2.submit(u'submit', status=302)
        res4 = res3.follow()
        # print res4
        self.assertTrue('Details for Member Application #3' in res4.body)

        # more asserts
        self.assertTrue('SomeFirstname' in res4.body)
        self.assertTrue('SomeLastname' in res4.body)
        self.assertTrue('[email protected]' in res4.body)
        self.assertTrue('addr one' in res4.body)
        self.assertTrue('addr two' in res4.body)
        self.assertTrue('12345' in res4.body)
        self.assertTrue('' in res4.body)
        self.assertTrue('DE' in res4.body)
        self.assertTrue('normal' in res4.body)
        self.assertTrue('23' in res4.body)

        # check the number of entries in the DB
        num = C3sMember.get_number()
        # print num
        self.assertTrue(num == 3)

        '''
        now add a legal entity / aka Körperschaft
        '''
        res = self.testapp.get('/new_member', status=200)

        form = res.form
        # print form.fields
        form['firstname'] = u'SomeLegalentity'
        form['lastname'] = u'SomeLegalName'
        form['email'] = u'[email protected]'
        form['address1'] = u"addr one"
        form['address2'] = u"addr two"
        form['postcode'] = u"12345"
        form['city'] = u"Footown Meeh"
        form['country'].value__set(u"DE")
        form['_LOCALE_'] = u"DE"
        form['date_of_birth'] = date.today()
        # form['email_is_confirmed=False,
        # email_confirm_code=u'ABCDEFGFOO',
        # password=u'arandompassword',
        # date_of_submission=date.today(),
        form['entity_type'] = u'legalentity'
        form['membership_type'] = u'investing'
        # form['deformField14'].value__set(u'normal')
        # form['other_colsoc'] = (u'no',),
        form['other_colsoc'].value__set(u'no')

        form['name_of_colsoc'] = u""
        form['num_shares'] = u'42'

        # try to submit the form (knowing that the date is missing)
        res2 = form.submit(u'submit', status=200)
        form2 = res2.form
        form2['date_of_birth'] = u'1999-09-19'

        res3 = form2.submit(u'submit', status=302)
        res4 = res3.follow()
        # print res4
        self.assertTrue('Details for Member Application #4' in res4.body)

        # more asserts
        self.assertTrue('SomeLegalentity' in res4.body)
        self.assertTrue('SomeLegalName' in res4.body)
        self.assertTrue('[email protected]' in res4.body)
        self.assertTrue('addr one' in res4.body)
        self.assertTrue('addr two' in res4.body)
        self.assertTrue('12345' in res4.body)
        self.assertTrue('' in res4.body)
        self.assertTrue('DE' in res4.body)
        self.assertTrue('investing' in res4.body)
        self.assertTrue('23' in res4.body)

        # check the number of entries in the DB
        num = C3sMember.get_number()
        # print num
        self.assertTrue(num == 4)
开发者ID:,项目名称:,代码行数:104,代码来源:

示例11: accountants_desk

# 需要导入模块: from c3smembership.models import C3sMember [as 别名]
# 或者: from c3smembership.models.C3sMember import get_number [as 别名]
def accountants_desk(request):
    """
    This view lets accountants view applications and set their status:
    has their signature arrived? how about the payment?
    """
    _number_of_datasets = C3sMember.get_number()
    try:  # check if page number, orderby and order were supplied with the URL
        _page_to_show = int(request.matchdict['number'])
        _order_by = request.matchdict['orderby']
        _order = request.matchdict['order']
    except:
        print("Using default values")
        _page_to_show = 0
        _order_by = 'id'
        _order = 'asc'

    # check for input from "find dataset by confirm code" form
    if 'code_to_show' in request.POST:
        try:
            _code = request.POST['code_to_show']
            log.info(
                "%s searched for code %s" % (
                    authenticated_userid(request), _code))
            _entry = C3sMember.get_by_code(_code)

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

    """
    num_display determines how many items are to be shown on one page
    """
    if 'num_to_show' in request.POST:
        try:
            _num = int(request.POST['num_to_show'])
            if isinstance(_num, type(1)):
                num_display = _num
        except:
            # choose default
            num_display = 20
    elif 'num_display' in request.cookies:
        #print("found it in cookie")
        num_display = int(request.cookies['num_display'])
    else:
        #print("setting default")
        num_display = request.registry.settings[
            'c3smembership.dashboard_number']

    """
    base_offset helps us to minimize impact on the database
    when querying for results.
    we can choose just those results we need for the page to show
    """
    base_offset = int(_page_to_show) * int(num_display)

    # get data sets from DB

    _members = C3sMember.member_listing(
        _order_by, how_many=num_display, offset=base_offset, order=_order)

    # calculate next-previous-navi
    next_page = (int(_page_to_show) + 1)
    if (int(_page_to_show) > 0):
        previous_page = int(_page_to_show) - 1
    else:
        previous_page = int(_page_to_show)
    _last_page = int(math.ceil(_number_of_datasets / int(num_display)))
    if next_page > _last_page:
        next_page = _last_page
    # store info about current page in cookie
    request.response.set_cookie('on_page', value=str(_page_to_show))
    request.response.set_cookie('num_display', value=str(num_display))
    request.response.set_cookie('order', value=str(_order))
    request.response.set_cookie('orderby', value=str(_order_by))



    _message = None
    if 'message' in request.GET:
        _message = request.GET['message']

    return {'_number_of_datasets': _number_of_datasets,
            'members': _members,
            'num_display': num_display,
            'next': next_page,
            'previous': previous_page,
            'current': _page_to_show,
            'orderby': _order_by,
            'order': _order,
            'message': _message,
            'last_page': _last_page,
            'is_last_page': _page_to_show == _last_page,
            'is_first_page': _page_to_show == 0,
            }
开发者ID:krissik,项目名称:c3sMembership,代码行数:100,代码来源:accountants_views.py

示例12: member_list_date_pdf_view

# 需要导入模块: from c3smembership.models import C3sMember [as 别名]
# 或者: from c3smembership.models.C3sMember import get_number [as 别名]
def member_list_date_pdf_view(request):
    """
    The membership list *for a given date* for printout as PDF.
    The date is supplied in and parsed from the URL, e.g.
    http://0.0.0.0:6543/aml-2014-12-31.pdf

    The PDF is generated using pdflatex.

    If the date is not parseable, an error message is shown.
    """
    try:
        _date_m = request.matchdict['date']
        _date = datetime.strptime(_date_m, '%Y-%m-%d').date()
    except (KeyError, ValueError):
        request.session.flash(
            "Invalid date! '{}' does not compute! "
            "try again, please! (YYYY-MM-DD)".format(
                _date_m),
            'message_to_user'
        )
        return HTTPFound(request.route_url('error_page'))

    """
    All member entries are loaded.
    """
    # query the database
    _order_by = 'lastname'
    _num = C3sMember.get_number()
    _all_members = C3sMember.member_listing(
        _order_by, how_many=_num, offset=0, order=u'asc')

    # prepare variables
    _members = []  # the members, filtered
    _count_members = 0  # count those members
    _count_shares = 0  # count their shares
    _count_shares_printed = 0  # cross-check...

    """
    ...and filtered for

    * active members (membership_accepted)
    * with membership numbers (cross-check)
    * who have become members before the given date.

    They are added to a list and counted.
    Their shares (those acquired before the date) are counted as well.
    """
    # filter and count memberships and shares
    for item in _all_members:
        if (
                (item.membership_number is not None) and
                item.is_member(_date)):
            # add this item to the filtered list of members
            _members.append(item)
            _count_members += 1
            # also count their shares iff acquired in the timespan
            for share in item.shares:
                if (date(
                        share.date_of_acquisition.year,
                        share.date_of_acquisition.month,
                        share.date_of_acquisition.day,
                ) <= _date):
                    _count_shares += share.number

    """
    The list of members is then sorted by

    * their given name
    * their last name,

    using locale.strcoll with german locale.
    This achieves a sort order like in phone books.
    """

    # sort members alphabetically
    import locale
    locale.setlocale(locale.LC_ALL, "de_DE.UTF-8")
    # ...by fist name
    _members.sort(key=lambda x: x.firstname, cmp=locale.strcoll)
    # ...and then by their last name
    _members.sort(key=lambda x: x.lastname, cmp=locale.strcoll)

    """
    Then a LaTeX file is constructed...
    """
    here = os.path.dirname(__file__)
    latex_header_tex = os.path.abspath(
        os.path.join(here, '../membership_list_pdflatex/header'))
    latex_footer_tex = os.path.abspath(
        os.path.join(here, '../membership_list_pdflatex/footer'))

    # a temporary directory for the latex run
    _tempdir = tempfile.mkdtemp()
    # now we prepare a .tex file to be pdflatex'ed
    latex_file = tempfile.NamedTemporaryFile(
        suffix='.tex',
        dir=_tempdir,
        delete=False,  # directory will be deleted anyways
    )
    # and where to store the output
#.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:103,代码来源:

示例13: accountants_desk

# 需要导入模块: from c3smembership.models import C3sMember [as 别名]
# 或者: from c3smembership.models.C3sMember import get_number [as 别名]
def accountants_desk(request):
    """
    This view lets accountants view applications and set their status:
    has their signature arrived? how about the payment?
    """
    _number_of_datasets = C3sMember.get_number()
    try:  # check if page number, orderby and order were supplied with the URL
        _page_to_show = int(request.matchdict['number'])
        _order_by = request.matchdict['orderby']
        _order = request.matchdict['order']
    except:
        #print("Using default values")
        _page_to_show = 0
        _order_by = 'id'
        _order = 'asc'

    # check for input from "find dataset by confirm code" form
    if 'code_to_show' in request.POST:
        try:
            _code = request.POST['code_to_show']
            log.info(
                "%s searched for code %s" % (
                    authenticated_userid(request), _code))
            _entry = C3sMember.get_by_code(_code)

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

    """
    num_display determines how many items are to be shown on one page
    """
    if 'num_to_show' in request.POST:
        try:
            _num = int(request.POST['num_to_show'])
            if isinstance(_num, type(1)):
                num_display = _num
        except:
            # choose default
            num_display = 20
    elif 'num_display' in request.cookies:
        #print("found it in cookie")
        num_display = int(request.cookies['num_display'])
    else:
        #print("setting default")
        num_display = request.registry.settings[
            'c3smembership.dashboard_number']

    '''
    we use a form with autocomplete to let staff find entries faster
    '''
    #the_codes = C3sMember.get_all_codes()
    #print("the codes: %s" % the_codes)

    class AutocompleteForm(colander.MappingSchema):
        code_to_show = colander.SchemaNode(
            colander.String(),
            title='Code finden (quicksearch; Groß-/Kleinschreibung beachten!)',
            #title='',
            widget=deform.widget.AutocompleteInputWidget(
                min_length=1,
                css_class="form-inline",
                #values=the_codes,  # XXX input matching ones only
                values=request.route_path(
                    'autocomplete_input_values',
                    traverse=('autocomplete_input_values')
                )
            )
        )

    schema = AutocompleteForm()
    form = deform.Form(
        schema,
        css_class="form-inline",
        buttons=('go!',),
    )
    autoformhtml = form.render()
    """
    base_offset helps us to minimize impact on the database
    when querying for results.
    we can choose just those results we need for the page to show
    """
    base_offset = int(_page_to_show) * int(num_display)

    # get data sets from DB
    _members = C3sMember.member_listing(
        _order_by, how_many=num_display, offset=base_offset, order=_order)

    # calculate next-previous-navi
    next_page = (int(_page_to_show) + 1)
    if (int(_page_to_show) > 0):
        previous_page = int(_page_to_show) - 1
    else:
        previous_page = int(_page_to_show)
    _last_page = int(math.ceil(_number_of_datasets / int(num_display)))
    if next_page > _last_page:
#.........这里部分代码省略.........
开发者ID:ebora,项目名称:c3sMembership,代码行数:103,代码来源:accountants_views.py

示例14: test_export

# 需要导入模块: from c3smembership.models import C3sMember [as 别名]
# 或者: from c3smembership.models.C3sMember import get_number [as 别名]
    def test_export(self):
        """
        load the login form, dashboard, start export, check outcome
        """
        # try unauthenticated
        res = self.testapp.get('/export_all', status=403)  # 403: forbidden
        # login
        res = self.testapp.get('/login', status=200)
        self.failUnless('login' in res.body)
        # try valid user, valid password
        form = res.form
        form['login'] = 'rut'
        form['password'] = 'berries'
        res2 = form.submit('submit', status=302)
        #
        # print('-'*30)
        # print(res2.body)
        # being logged in ...
        res3 = res2.follow()

        self.failUnless(
            'Dashboard' in res3.body)
        # now try authenticated
        export = tempfile.NamedTemporaryFile()
        export.write(self.testapp.get('/export_all', status=200).body)
        export.seek(0)  # rewind to start

        r = unicodecsv.reader(export.file, delimiter=';',
                              encoding='utf-8',
                              quoting=unicodecsv.QUOTE_ALL)
        header = r.next()
        # check header consistency
        self.assertTrue(
            header == [
                u'firstname', u'lastname', u'email',  # 1, 2, 3
                u'password', u'last_password_change',  # 3, 4
                u'address1', u'address2', u'postcode', u'city', u'country',
                u'locale', u'date_of_birth',  # 10, 11
                u'email_is_confirmed', u'email_confirm_code',  # 12, 13
                u'num_shares', u'date_of_submission',  # 14, 15
                u'membership_type',  # 16
                u'member_of_colsoc', u'name_of_colsoc',
                u'signature_received', u'signature_received_date',
                u'payment_received', u'payment_received_date',
                u'signature_confirmed', u'signature_confirmed_date',
                u'payment_confirmed', u'payment_confirmed_date',
                u'accountant_comment']
        )

        # check/compare database contents
        r1 = r.next()  # get next row fom CSV
        how_many = C3sMember.get_number()
        self.assertTrue(how_many is 1)
        crowd = C3sMember.member_listing(
            "id", how_many=C3sMember.get_number(), order="desc")

        self.assertTrue(u'SomeFirstnäme' in crowd[0].firstname)
        self.assertTrue(r1[0] in crowd[0].firstname)
        self.assertTrue(u'SomeLastnäme' in crowd[0].lastname)
        self.assertTrue(r1[1] in crowd[0].lastname)
        self.assertTrue('[email protected]' in crowd[0].email)
        self.assertTrue(r1[2] in crowd[0].email)

        self.assertTrue(str(r1[4]) in str(self.m1_last_pw_change))
        self.assertTrue(r1[5] in crowd[0].address1)
        self.assertTrue(r1[6] in crowd[0].address2)
        self.assertTrue(r1[7] in crowd[0].postcode)
        self.assertTrue(r1[8] in crowd[0].city)
        self.assertTrue(r1[9] in crowd[0].country)
        self.assertTrue(r1[10] in crowd[0].locale)
        self.assertTrue(r1[11] in str(crowd[0].date_of_birth))
        self.assertFalse(crowd[0].email_is_confirmed)
        self.assertTrue(r1[12] in u"False")
        self.assertTrue(r1[13] in crowd[0].email_confirm_code)
        self.assertTrue(str(r1[14]) == str(crowd[0].num_shares))
        self.assertTrue(
            r1[15] in str(crowd[0].date_of_submission))
        self.assertTrue('normal' in crowd[0].membership_type)
        self.assertTrue(r1[16] in crowd[0].membership_type)
        self.assertTrue(crowd[0].member_of_colsoc)
        self.assertTrue(r1[17] in "True")
        self.assertTrue(r1[18] in crowd[0].name_of_colsoc)
        self.assertTrue(crowd[0].name_of_colsoc in r1[18])
        self.assertTrue(str(r1[19]) in str(crowd[0].signature_received))
        self.assertTrue(
            r1[20] in str(
                crowd[0].signature_received_date))
        self.assertFalse(crowd[0].payment_received)
        self.assertTrue(str(r1[21]) in u'False')
        # print r1[22]
        # self.assertTrue(
        #     '1970-01-01 00:00:00' in str(crowd[0].payment_received_date))
        # print r1[23]
        # self.assertFalse(crowd[0].signature_confirmed)
        # print r1[24]
        # self.assertTrue(
        #     '1970-01-01 00:00:00' in str(
        #         crowd[0].signature_confirmed_date))
        # print r1[25]
        # self.assertFalse(crowd[0].payment_confirmed)
#.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:103,代码来源:

示例15: test_import

# 需要导入模块: from c3smembership.models import C3sMember [as 别名]
# 或者: from c3smembership.models.C3sMember import get_number [as 别名]
    def test_import(self):
        """
        load the login form, dashboard, start import, check outcome
        """
        # try unauthenticated
        res = self.testapp.get('/import_all', status=403)  # 403: forbidden
        # print res.body
        #
        # login
        #
        res = self.testapp.get('/login', status=200)
        self.failUnless('login' in res.body)
        # try valid user, valid password
        form = res.form
        form['login'] = 'rut'
        form['password'] = 'berries'
        res2 = form.submit('submit', status=302)
        #
        # print(res2.body)
        # being logged in ...
        res3 = res2.follow()
        # print '-#-' * 10
        # print res3.body
        self.failUnless(
            'Dashboard' in res3.body)
        # now try authenticated
        res = self.testapp.get('/import_all', status=302)
        res2 = res.follow()
        # print res2.body

        # XXX check database contents
        how_many = C3sMember.get_number()
        self.assertTrue(how_many is 3)
        crowd = C3sMember.member_listing(
            "id", how_many=C3sMember.get_number(), order="asc")
        self.assertTrue(u'SomeFirstnäme' in crowd[0].firstname)
        self.assertTrue('Alice' in crowd[1].firstname)
        self.assertTrue(u'Göbel' in crowd[1].lastname)
        self.assertTrue('[email protected]' in crowd[1].email)
        self.assertTrue(
            str(
                datetime.strptime(
                    '2013-12-26 13:33:37.422342',
                    '%Y-%m-%d %H:%M:%S.%f')
            ) in str(crowd[1].last_password_change))
        self.assertTrue(u'Horstmüller-Str. 16' in crowd[1].address1)
        self.assertTrue('' in crowd[1].address2)
        self.assertTrue('12345' in crowd[1].postcode)
        self.assertTrue('Hamburg' in crowd[1].city)
        self.assertTrue('DE' in crowd[1].country)
        self.assertTrue('de' in crowd[1].locale)
        self.assertTrue('1951-04-05' in str(crowd[1].date_of_birth))
        self.assertFalse(crowd[1].email_is_confirmed)
        self.assertTrue('SJWAI666LU' in crowd[1].email_confirm_code)
        self.assertTrue(crowd[1].num_shares is 1)
        self.assertTrue(
            '2013-12-29 15:30:23.422342' in str(crowd[1].date_of_submission))
        self.assertTrue('normal' in crowd[1].membership_type)
        self.assertFalse(crowd[1].member_of_colsoc)
        self.assertTrue('' in crowd[1].name_of_colsoc)
        self.assertTrue(crowd[1].signature_received)
        self.assertTrue(
            '2013-12-29 21:28:45.364342' in str(
                crowd[1].signature_received_date))
        self.assertFalse(crowd[1].payment_received)
        self.assertTrue(
            '1970-01-01 00:00:00' in str(crowd[1].payment_received_date))
        self.assertFalse(crowd[1].signature_confirmed)
        self.assertTrue(
            '1970-01-01 00:00:00' in str(
                crowd[1].signature_confirmed_date))
        self.assertFalse(crowd[1].payment_confirmed)
        self.assertTrue(
            '1970-01-01 00:00:00' in str(
                crowd[1].payment_confirmed_date))
        self.assertTrue('' in crowd[1].accountant_comment)
        #
        # test another row
        #
        self.assertTrue('Alize' in crowd[2].firstname)
        self.assertTrue(u'Görbel' in crowd[2].lastname)
        self.assertTrue('[email protected]' in crowd[2].email)
        self.assertTrue(
            str(
                datetime.strptime(
                    '2013-12-26 13:33:37.422342',
                    '%Y-%m-%d %H:%M:%S.%f'))
            in str(crowd[1].last_password_change))
        self.assertTrue(u'Horstmüller-Str. 23' in crowd[2].address1)
        self.assertTrue('addr2' in crowd[2].address2)
        self.assertTrue('12345' in crowd[2].postcode)
        self.assertTrue('Hamburg' in crowd[2].city)
        self.assertTrue('FR' in crowd[2].country)
        self.assertTrue('fr' in crowd[2].locale)
        self.assertTrue('1951-04-06' in str(crowd[2].date_of_birth))
        self.assertTrue(crowd[2].email_is_confirmed)
        self.assertTrue('SJWAI666LT' in crowd[2].email_confirm_code)
        self.assertTrue(crowd[2].num_shares is 2)
        self.assertTrue(
            '2013-12-29 15:30:42.422342' in str(crowd[2].date_of_submission))
#.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:103,代码来源:


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