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


Python C3sMember.get_next_free_membership_number方法代码示例

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


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

示例1: stats_view

# 需要导入模块: from c3smembership.data.model.base.c3smember import C3sMember [as 别名]
# 或者: from c3smembership.data.model.base.c3smember.C3sMember import get_next_free_membership_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)
    share_information = request.registry.share_information
    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_members': share_information.get_share_count(),
        # '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(),
        'num_membership_lost': C3sMember.get_num_membership_lost(),
        # 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,

        # dues stats
        'dues15_stats': DuesInvoiceRepository.get_monthly_stats(2015),
        'dues16_stats': DuesInvoiceRepository.get_monthly_stats(2016),
        'dues17_stats': DuesInvoiceRepository.get_monthly_stats(2017),
        'dues18_stats': DuesInvoiceRepository.get_monthly_stats(2018),
        'dues19_stats': DuesInvoiceRepository.get_monthly_stats(2019),

        # staff figures
        'num_staff': len(Staff.get_all())
    }
开发者ID:C3S,项目名称:c3sMembership,代码行数:58,代码来源:statistics.py

示例2: make_member_view

# 需要导入模块: from c3smembership.data.model.base.c3smember import C3sMember [as 别名]
# 或者: from c3smembership.data.model.base.c3smember.C3sMember import get_next_free_membership_number [as 别名]
def make_member_view(request):
    """
    Turns a membership applicant into an accepted member.

    When both the signature and the payment for the shares have arrived at
    headquarters, an application for membership can be turned into an
    **accepted membership**, if the board of directors decides so.

    This view lets staff enter a date of approval through a form.

    It also provides staff with listings of

    * members with same first name
    * members with same last name
    * members with same email address
    * members with same date of birth

    so staff can decide if this may become a proper membership
    or whether this application is a duplicate of some accepted membership
    and should be merged with some other entry.

    In case of duplicate/merge, also check if the number of shares
    when combining both entries would exceed 60,
    the maximum number of shares a member can hold.
    """
    afm_id = request.matchdict['afm_id']
    try:  # does that id make sense? member exists?
        member = C3sMember.get_by_id(afm_id)
        assert(isinstance(member, C3sMember))  # is an application
        # assert(isinstance(member.membership_number, NoneType)
        # not has number
    except AssertionError:
        return HTTPFound(
            location=request.route_url('dashboard'))
    if member.membership_accepted:
        request.session.flash('id {} is already accepted member!', 'danger')
        return HTTPFound(request.route_url('detail', member_id=member.id))

    if not (member.signature_received and member.payment_received):
        request.session.flash('signature or payment missing!', 'danger')
        return HTTPFound(request.route_url('dashboard'))

    if 'make_member' in request.POST:
        # print "yes! contents: {}".format(request.POST['make_member'])
        try:
            member.membership_date = datetime.strptime(
                request.POST['membership_date'], '%Y-%m-%d').date()
        except ValueError, value_error:
            request.session.flash(value_error.message, 'danger')
            return HTTPFound(
                request.route_url('make_member', afm_id=member.id))

        member.membership_accepted = True
        if member.is_legalentity:
            member.membership_type = u'investing'
        else:
            member.is_legalentity = False
        member.membership_number = C3sMember.get_next_free_membership_number()

        # Currently, the inconsistent data model stores the amount of applied
        # shares in member.num_shares which must be moved to a membership
        # application process property. As the acquisition of shares increases
        # the amount of shares and this is still read from member.num_shares,
        # this value must first be reset to 0 so that it can be increased by
        # the share acquisition. Once the new data model is complete the
        # property num_shares will not exist anymore. Instead, a membership
        # application process stores the number of applied shares and the
        # shares store the number of actual shares.
        num_shares = member.num_shares
        member.num_shares = 0

        share_id = request.registry.share_acquisition.create(
            member.membership_number,
            num_shares,
            member.membership_date)
        share_acquisition = request.registry.share_acquisition
        share_acquisition.set_signature_reception(
            share_id,
            date(
                member.signature_received_date.year,
                member.signature_received_date.month,
                member.signature_received_date.day))
        share_acquisition.set_signature_confirmation(
            share_id,
            date(
                member.signature_confirmed_date.year,
                member.signature_confirmed_date.month,
                member.signature_confirmed_date.day))
        share_acquisition.set_payment_reception(
            share_id,
            date(
                member.payment_received_date.year,
                member.payment_received_date.month,
                member.payment_received_date.day))
        share_acquisition.set_payment_confirmation(
            share_id,
            date(
                member.payment_confirmed_date.year,
                member.payment_confirmed_date.month,
                member.payment_confirmed_date.day))
#.........这里部分代码省略.........
开发者ID:C3S,项目名称:c3sMembership,代码行数:103,代码来源:membership_member_grant.py

示例3: test_membership_application

# 需要导入模块: from c3smembership.data.model.base.c3smember import C3sMember [as 别名]
# 或者: from c3smembership.data.model.base.c3smember.C3sMember import get_next_free_membership_number [as 别名]

#.........这里部分代码省略.........
        self.assertTrue('Type of Membership:normal' in body)
        self.assertTrue('Member of other Collecting Society: yes' in body)
        self.assertTrue('Membership(s): Svenska Tonsättares Internationella Musikbyrå' in body)
        self.assertTrue('Number of Shares: 15' in body)
        self.assertTrue('Cost of Shares (50 € each): 750 €' in body)
        res = self.testapp.get('/check_email', status=200)

        # 3. Verify sent confirmation email
        mailer = self.get_mailer(None)
        email = mailer.get_email()
        self.assertEqual(email.recipients, ['[email protected]'])
        self.assertEqual(email.subject, 'C3S: confirm your email address and load your PDF')

        # 4. Confirm email address via confirmation link
        match = re.search(
            'localhost(?P<url>[^\s]+)',
            email.body)

        self.assertTrue(match is not None)
        res = self.testapp.get(
            match.group('url'),
            status=200)

        self.assertTrue(u'password in order to verify your email' in res.body)
        res.form['password'] = 'worst password ever chosen'
        res = res.form.submit(u'submit', status=200)

        # 5. Login to backend
        self.testapp.reset()
        self._login()

        # 6. Verify applicant's detail page
        member_id = DBSession.query(func.max(C3sMember.id)).scalar()
        res = self.testapp.get('/detail/{0}'.format(member_id), status=200)

        body = self._response_to_bare_text(res)
        self.assertTrue('Firstname Sönke' in body)
        self.assertTrue('Lastname Blømqvist' in body)
        self.assertTrue('Email address [email protected]' in body)
        self.assertTrue('Email address confirmed Yes' in body)
        self.assertTrue('Address line 1 ℅ Big Boss' in body)
        self.assertTrue('Address line 2 Håkanvägen 12' in body)
        self.assertTrue('Postcode ABC1234' in body)
        self.assertTrue('City Stockholm' in body)
        self.assertTrue('Country SE' in body)
        self.assertTrue('Date of birth 1980-01-02' in body)
        self.assertTrue('Membership accepted  No' in body)
        self.assertTrue('Entity type Natural person' in body)
        self.assertTrue('Membership type normal' in body)
        self.assertTrue('Member of collecting societies Yes Svenska Tonsättares Internationella Musikbyrå' in body)
        self.assertTrue('Date of submission' in body)
        self.assertTrue('Signature received    No' in body)
        self.assertTrue('Signature confirmed No' in body)
        self.assertTrue('Payment received   No' in body)
        self.assertTrue('Payment confirmed No' in body)
        self.assertTrue('Shares  Total: 15' in body)
        # TODO:
        # - code
        # - locale, set explicitly and test both German and English
        # - date of submission

        # 7. Set payment received
        res = self.testapp.get(
            '/switch_pay/{0}'.format(member_id),
            headers={'Referer': 'asdf'},
            status=302)
        res = res.follow()
        body = self._response_to_bare_text(res)
        self.assertTrue('Payment received    Yes' in body)
        self.assertTrue('Payment reception date 2018-04-26 12:23:34' in body)

        # 8. Set signature received
        res = self.testapp.get(
            '/switch_sig/{0}'.format(member_id),
            headers={'Referer': 'asdf'},
            status=302)
        res = res.follow()
        body = self._response_to_bare_text(res)
        self.assertTrue('Signature received    Yes' in body)
        self.assertTrue('Signature reception date 2018-04-26 12:23:34' in body)

        # 9. Make member
        res = self.testapp.get(
            '/make_member/{0}'.format(member_id),
            headers={'Referer': 'asdf'},
            status=200)
        res.form['membership_date'] = '2018-04-27'
        res = res.form.submit('submit', status=302)
        res = res.follow()

        # 10. Verify member details
        membership_number = C3sMember.get_next_free_membership_number() - 1
        body = self._response_to_bare_text(res)
        self.assertTrue('Membership accepted  Yes' in body)
        self.assertTrue(
            'Membership number  {0}'.format(membership_number) in body)
        self.assertTrue('Membership date 2018-04-27' in body)
        self.assertTrue('Shares  Total: 15' in body)
        self.assertTrue('1 package(s)' in body)
        self.assertTrue('15 shares   (2018-04-27)' in body)
开发者ID:C3S,项目名称:c3sMembership,代码行数:104,代码来源:test_membership_application.py

示例4: HTTPFound

# 需要导入模块: from c3smembership.data.model.base.c3smember import C3sMember [as 别名]
# 或者: from c3smembership.data.model.base.c3smember.C3sMember import get_next_free_membership_number [as 别名]
        share_acquisition.set_reference_code(
            share_id,
            member.email_confirm_code)

        # return the user to the page she came from
        if 'referrer' in request.POST:
            if request.POST['referrer'] == 'dashboard':
                return HTTPFound(request.route_url('dashboard'))
            if request.POST['referrer'] == 'detail':
                return HTTPFound(
                    request.route_url('detail', member_id=member.id))
        return HTTPFound(request.route_url('detail', member_id=member.id))

    referrer = ''
    if 'dashboard' in request.referrer:
        referrer = 'dashboard'
    if 'detail' in request.referrer:
        referrer = 'detail'
    return {
        'member': member,
        'next_mship_number': C3sMember.get_next_free_membership_number(),
        'same_mships_firstn': C3sMember.get_same_firstnames(member.firstname),
        'same_mships_lastn': C3sMember.get_same_lastnames(member.lastname),
        'same_mships_email': C3sMember.get_same_email(member.email),
        'same_mships_dob': C3sMember.get_same_date_of_birth(
            member.date_of_birth),
        # keep information about the page the user came from in order to
        # return her to this page
        'referrer': referrer,
    }
开发者ID:C3S,项目名称:c3sMembership,代码行数:32,代码来源:membership_member_grant.py

示例5: edit_member

# 需要导入模块: from c3smembership.data.model.base.c3smember import C3sMember [as 别名]
# 或者: from c3smembership.data.model.base.c3smember.C3sMember import get_next_free_membership_number [as 别名]

#.........这里部分代码省略.........
            ('locale', appstruct['person']['locale']),
            (
                'membership_date',
                appstruct['membership_meta']['membership_date']
            ),
            ('is_duplicate', appstruct['membership_meta']['is_duplicate']),
            (
                'is_duplicate_of',
                appstruct['membership_meta']['is_duplicate_of']
            ),
            (
                'accountant_comment',
                appstruct['membership_meta']['accountant_comment']
            ),
            (
                'membership_type',
                appstruct['membership_info']['membership_type']
            ),
            (
                'is_legalentity',
                1 if (appstruct['membership_info']['entity_type'] ==
                      'legalentity')
                else 0
            ),
            (
                'name_of_colsoc',
                appstruct['membership_info']['name_of_colsoc']
            ),
            (
                'signature_received',
                appstruct['membership_meta']['signature_received']
            ),
            (
                'signature_received_date',
                appstruct['membership_meta']['signature_received_date']
            ),
            (
                'payment_received',
                appstruct['membership_meta']['payment_received']
            ),
            (
                'payment_received_date',
                appstruct['membership_meta']['payment_received_date']
            ),
            (
                'membership_loss_type',
                appstruct['membership_meta'].get('membership_loss_type', None)
            ),
            (
                'membership_loss_date',
                appstruct['membership_meta'].get('membership_loss_date', None)
            ),
        ]

        for thing in listing:
            attribute_name = thing[0]
            attribute_value = thing[1]

            if member.__getattribute__(attribute_name) == attribute_value:
                pass
            else:
                LOG.info(
                    u'{0} changes {1} of id {2} to {3}'.format(
                        authenticated_userid(request),
                        attribute_name,
                        member.id,
                        attribute_value
                    )
                )
                setattr(member, attribute_name, attribute_value)

        # membership acceptance status can be set or unset.
        if appstruct['membership_meta'][
                'membership_accepted'] == member.membership_accepted:
            pass
        else:
            member.membership_accepted = appstruct[
                'membership_meta']['membership_accepted']
            if isinstance(member.membership_number, NoneType) \
                    and member.membership_accepted:
                member.membership_number = \
                    C3sMember.get_next_free_membership_number()

        if appstruct['membership_info']['entity_type'] == 'legalentity':
            member.is_legalentity = True
        else:
            member.is_legalentity = False

        # empty the messages queue (as validation worked anyways)
        request.session.pop_flash()
        return HTTPFound(  # redirect to details page
            location=request.route_url(
                'detail',
                member_id=member.id),
        )

    form.set_appstruct(appstruct)
    html = form.render()

    return {'form': html}
开发者ID:C3S,项目名称:c3sMembership,代码行数:104,代码来源:membership_member_edit.py


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