本文整理汇总了Python中c3smembership.models.C3sMember.get_all方法的典型用法代码示例。如果您正苦于以下问题:Python C3sMember.get_all方法的具体用法?Python C3sMember.get_all怎么用?Python C3sMember.get_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类c3smembership.models.C3sMember
的用法示例。
在下文中一共展示了C3sMember.get_all方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_invitation_batch
# 需要导入模块: from c3smembership.models import C3sMember [as 别名]
# 或者: from c3smembership.models.C3sMember import get_all [as 别名]
def test_invitation_batch(self):
"""
Test the invitation procedure, batch mode.
"""
from c3smembership.invite_members import batch_invite
all = C3sMember.get_all()
for m in all:
self.assertEqual(m.email_invite_flag_bcgv16, False)
self.assertTrue(m.email_invite_token_bcgv16 is None)
self.assertTrue(m.membership_accepted is True)
req = testing.DummyRequest()
# have some cookies
req.cookies['on_page'] = 0
req.cookies['order'] = 'asc'
req.cookies['orderby'] = 'id'
# with matchdict
req.matchdict = {'number': 1} # this will trigger 1 invitation
res = batch_invite(req)
_messages = req.session.peek_flash('message_to_staff')
# print("messages: {}".format(_messages))
self.assertTrue(
'sent out 1 mails (to members with ids [1]' in _messages)
# without matchdict
req.matchdict = {'number': ''} # this triggers remaining 3
res = batch_invite(req)
self.assertEqual(res.status_code, 302)
_messages = req.session.peek_flash('message_to_staff')
# print("messages: {}".format(_messages))
self.assertTrue(
'sent out 3 mails (to members with ids [2, 3, 4]' in _messages)
# send more request with POST['number']
req = testing.DummyRequest(
POST={
'number': 'foo',
'submit': True,
})
res = batch_invite(req)
req = testing.DummyRequest(
POST={
'number': 1,
'submit': True,
})
res = batch_invite(req)
_messages = req.session.peek_flash('message_to_staff')
# print("messages: {}".format(_messages))
self.assertTrue(
'no invitees left. all done!' in _messages)
mailer = get_mailer(req)
self.assertEqual(len(mailer.outbox), 4)
# assumptions about those members and emails sent
self.assertTrue('[C3S] Einladung' in mailer.outbox[0].subject) # de
self.assertTrue('[C3S] Invitation' in mailer.outbox[1].subject) # en
self.assertTrue('[C3S] Einladung' in mailer.outbox[2].subject) # de
self.assertTrue('[C3S] Invitation' in mailer.outbox[3].subject) # en
for m in all:
# has been invited
self.assertEqual(m.email_invite_flag_bcgv16, True)
# has a token
self.assertTrue(m.email_invite_token_bcgv16 is not None)
# firstname and token are in email body
self.assertTrue(
all[m.id - 1].firstname in mailer.outbox[m.id - 1].body)
self.assertTrue(
all[m.id - 1].email_invite_token_bcgv16 in mailer.outbox[
m.id - 1].body)
示例2:
# 需要导入模块: from c3smembership.models import C3sMember [as 别名]
# 或者: from c3smembership.models.C3sMember import get_all [as 别名]
'num_shares': 0,
'new_members': [],
'paid_unapproved_shares': [],
'num_shares_paid_unapproved': 0,
'sum_shares': 0,
'new_shares': [],
'start_date': start_date,
'end_date': end_date,
}
else: # if form not submitted, preload values
form.set_appstruct(appstruct)
# prepare: get information from the database
# get memberships
all_members = C3sMember.get_all()
# prepare filtering and counting
members = [] # all the members matching the criteria
members_count = 0
afm_shares_paid_unapproved_cnt = 0
afm_shares_paid_unapproved = []
# now filter and count the afms and members
for member in all_members:
if (
member.membership_accepted and # unneccessary!?
(member.membership_date >= start_date) and
(member.membership_date <= end_date)
):
示例3: _initTestingDB
# 需要导入模块: from c3smembership.models import C3sMember [as 别名]
# 或者: from c3smembership.models.C3sMember import get_all [as 别名]
def _initTestingDB():
my_settings = {
'sqlalchemy.url': 'sqlite:///:memory:', }
engine = engine_from_config(my_settings)
DBSession.configure(bind=engine)
Base.metadata.create_all(engine)
with transaction.manager:
# There is a side effect of test_initialization.py after which there are
# still records in the database although it is setup from scratch.
# Therefore, remove all members to have an empty table.
members = C3sMember.get_all()
for member in members:
DBSession.delete(member)
DBSession.flush()
member1 = C3sMember( # german person
firstname=u'SomeFirstnäme',
lastname=u'SomeLastnäme',
email=u'[email protected]',
address1=u"addr one",
address2=u"addr two",
postcode=u"12345",
city=u"Footown Mäh",
country=u"Foocountry",
locale=u"de",
date_of_birth=date.today(),
email_is_confirmed=False,
email_confirm_code=u'ABCDEFG1',
password=u'arandompassword',
date_of_submission=date.today(),
membership_type=u'normal',
member_of_colsoc=False,
name_of_colsoc=u"",
num_shares=u'23',
)
member2 = C3sMember( # english person
firstname=u'AAASomeFirstnäme',
lastname=u'XXXSomeLastnäme',
email=u'[email protected]',
address1=u"addr one",
address2=u"addr two",
postcode=u"12345",
city=u"Footown Mäh",
country=u"Foocountry",
locale=u"en",
date_of_birth=date.today(),
email_is_confirmed=False,
email_confirm_code=u'ABCDEFG2',
password=u'arandompassword',
date_of_submission=date.today(),
membership_type=u'normal',
member_of_colsoc=False,
name_of_colsoc=u"",
num_shares=u'23',
)
member3 = C3sMember( # german legalentity
firstname=u'Cooles PlattenLabel',
lastname=u'SomeLastnäme',
email=u'[email protected]',
address1=u"addr one",
address2=u"addr two",
postcode=u"12345",
city=u"Footown Mäh",
country=u"Foocountry",
locale=u"de",
date_of_birth=date.today(),
email_is_confirmed=False,
email_confirm_code=u'ABCDEFG3',
password=u'arandompassword',
date_of_submission=date.today(),
membership_type=u'normal',
member_of_colsoc=False,
name_of_colsoc=u"",
num_shares=u'42',
)
member4 = C3sMember( # english legalentity
firstname=u'Incredible Records',
lastname=u'XXXSomeLastnäme',
email=u'[email protected]',
address1=u"addr one",
address2=u"addr two",
postcode=u"12345",
city=u"Footown Mäh",
country=u"Foocountry",
locale=u"en",
date_of_birth=date.today(),
email_is_confirmed=False,
email_confirm_code=u'ABCDEFG4',
password=u'arandompassword',
date_of_submission=date.today(),
membership_type=u'normal',
member_of_colsoc=False,
name_of_colsoc=u"",
num_shares=u'2',
)
member1.membership_accepted = True
DBSession.add(member1)
member2.membership_accepted = True
DBSession.add(member2)
#.........这里部分代码省略.........