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


Python C3sMember.member_listing方法代码示例

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


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

示例1: member_list_print_view

# 需要导入模块: from c3smembership.models import C3sMember [as 别名]
# 或者: from c3smembership.models.C3sMember import member_listing [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: export_yes_emails

# 需要导入模块: from c3smembership.models import C3sMember [as 别名]
# 或者: from c3smembership.models.C3sMember import member_listing [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

示例3: export_yes_emails

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

示例4: export_db

# 需要导入模块: from c3smembership.models import C3sMember [as 别名]
# 或者: from c3smembership.models.C3sMember import member_listing [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

示例5: accountants_desk

# 需要导入模块: from c3smembership.models import C3sMember [as 别名]
# 或者: from c3smembership.models.C3sMember import member_listing [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

示例6: member_list_date_pdf_view

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

示例7: test_export

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

示例8: test_import

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

示例9: accountants_desk

# 需要导入模块: from c3smembership.models import C3sMember [as 别名]
# 或者: from c3smembership.models.C3sMember import member_listing [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

示例10: accountants_desk

# 需要导入模块: from c3smembership.models import C3sMember [as 别名]
# 或者: from c3smembership.models.C3sMember import member_listing [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

示例11: accountants_desk

# 需要导入模块: from c3smembership.models import C3sMember [as 别名]
# 或者: from c3smembership.models.C3sMember import member_listing [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()
    # print("request.matchdict['number']: %s" % request.matchdict['number'])
    try:  # check if
        # a page number was supplied with the URL
        _page_to_show = int(request.matchdict["number"])
        # print("page to show: %s" % _page_to_show)
    except:
        _page_to_show = 0
    # is it a number? yes, cast above
    # if not isinstance(_page_to_show, type(1)):
    #    _page_to_show = 0
    # print("_page_to_show: %s" % _page_to_show)

    # how many to display on one page?
    """
    num_display determines how many items are to be shown on one page
    """
    # print request.POST
    if "num_to_show" in request.POST:
        # print("found it in 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"]
    # print("num_display: %s " % num_display)

    """
    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
    """
    # try:
    base_offset = int(_page_to_show) * int(num_display)
    # print("base offset: %s" % base_offset)
    # except:
    #    base_offset = 0
    #    if 'base_offset' in request.session:
    #        base_offset = request.session['base_offset']
    #    else:
    #        base_offset = request.registry.settings['c3smembership.offset']

    # get data sets from DB
    _members = C3sMember.member_listing(C3sMember.id.desc(), how_many=num_display, offset=base_offset)

    # 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)

    # store info about current page in cookie
    request.response.set_cookie("on_page", value=str(_page_to_show))
    # print("num_display: %s" % num_display)
    request.response.set_cookie("num_display", value=str(num_display))

    return {
        "_number_of_datasets": _number_of_datasets,
        "members": _members,
        "num_display": num_display,
        "next": next_page,
        "previous": previous_page,
    }
开发者ID:hedgeburner,项目名称:c3sMembership,代码行数:79,代码来源:accountants_views.py


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