本文整理汇总了Python中c3smembership.data.model.base.c3smember.C3sMember.get_all方法的典型用法代码示例。如果您正苦于以下问题:Python C3sMember.get_all方法的具体用法?Python C3sMember.get_all怎么用?Python C3sMember.get_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类c3smembership.data.model.base.c3smember.C3sMember
的用法示例。
在下文中一共展示了C3sMember.get_all方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_invitation_batch
# 需要导入模块: from c3smembership.data.model.base.c3smember import C3sMember [as 别名]
# 或者: from c3smembership.data.model.base.c3smember.C3sMember import get_all [as 别名]
def test_invitation_batch(self):
"""
Test the invitation procedure, batch mode.
"""
members = C3sMember.get_all()
for member in members:
invitation = GeneralAssemblyRepository.get_member_invitation(
member.membership_number, CURRENT_GENERAL_ASSEMBLY)
self.assertEqual(invitation['flag'], False)
self.assertTrue(invitation['token'] is None)
self.assertTrue(member.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
general_assembly = mock.Mock()
general_assembly.number = CURRENT_GENERAL_ASSEMBLY
req.validated_post = {'count': 1}
req.validated_matchdict = {
'general_assembly': general_assembly
}
invitees = GeneralAssemblyRepository.get_invitees(
CURRENT_GENERAL_ASSEMBLY, 1000)
self.assertEquals(len(invitees), 4)
res = batch_invite(req)
_messages = req.session.peek_flash('success')
self.assertTrue(
'sent out 1 mails (to members with membership numbers'
in _messages[0])
invitees = GeneralAssemblyRepository.get_invitees(
CURRENT_GENERAL_ASSEMBLY, 1000)
self.assertEquals(len(invitees), 3)
# without matchdict
general_assembly = mock.Mock()
general_assembly.number = CURRENT_GENERAL_ASSEMBLY
req.validated_matchdict = {
'general_assembly': general_assembly
}
req.validated_post = {'count': 5}
res = batch_invite(req)
invitees = GeneralAssemblyRepository.get_invitees(
CURRENT_GENERAL_ASSEMBLY, 1000)
self.assertEquals(len(invitees), 0)
self.assertEqual(res.status_code, 302)
_messages = req.session.peek_flash('success')
self.assertTrue(
'sent out 3 mails (to members with membership numbers'
in _messages[1])
# send more request with POST['number']
req = testing.DummyRequest()
general_assembly = mock.Mock()
general_assembly.number = CURRENT_GENERAL_ASSEMBLY
req.validated_matchdict = {'general_assembly': general_assembly}
req.validated_post = {'count': 5}
res = batch_invite(req)
req = testing.DummyRequest()
general_assembly = mock.Mock()
general_assembly.number = CURRENT_GENERAL_ASSEMBLY
req.validated_matchdict = {'general_assembly': general_assembly}
req.validated_post = {'count': 5}
res = batch_invite(req)
_messages = req.session.peek_flash('success')
self.assertTrue(
'no invitees left. all done!' in _messages)
mailer = get_mailer(req)
self.assertEqual(len(mailer.outbox), 4)
示例2: init_testing_db
# 需要导入模块: from c3smembership.data.model.base.c3smember import C3sMember [as 别名]
# 或者: from c3smembership.data.model.base.c3smember.C3sMember import get_all [as 别名]
def init_testing_db():
"""
Initializes the memory database with test samples.
"""
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.
# pylint: disable=no-member
members = C3sMember.get_all()
for member in members:
DBSession.delete(member)
DBSession.flush()
DBSession.add(GeneralAssembly(
GENERAL_ASSEMBLY_NUMBER_2014,
u'1. ordentliche Generalversammlung',
date(2014, 8, 23)))
DBSession.add(GeneralAssembly(
GENERAL_ASSEMBLY_NUMBER_2015,
u'2. ordentliche Generalversammlung',
date(2015, 6, 13)))
DBSession.add(GeneralAssembly(
GENERAL_ASSEMBLY_NUMBER_2015_2,
u'Außerordentliche Generalversammlung',
date(2015, 7, 16)))
DBSession.add(GeneralAssembly(
GENERAL_ASSEMBLY_NUMBER_2016,
u'3. ordentliche Generalversammlung',
date(2016, 4, 17)))
DBSession.add(GeneralAssembly(
GENERAL_ASSEMBLY_NUMBER_2017,
u'4. ordentliche Generalversammlung',
date(2017, 4, 2)))
DBSession.add(GeneralAssembly(
GENERAL_ASSEMBLY_NUMBER_2018,
u'5. ordentliche Generalversammlung',
date(2018, 6, 3)))
DBSession.add(GeneralAssembly(
GENERAL_ASSEMBLY_NUMBER_2018_2,
u'Außerordentliche Generalversammlung',
date(2018, 12, 1)))
# German person
member1 = C3sMember(
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',
)
# English person
member2 = C3sMember(
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',
)
# German legal entity
member3 = C3sMember(
firstname=u'Cooles PlattenLabel',
lastname=u'SomeLastnäme',
email=u'[email protected]',
address1=u"addr one",
address2=u"addr two",
#.........这里部分代码省略.........
示例3:
# 需要导入模块: from c3smembership.data.model.base.c3smember import C3sMember [as 别名]
# 或者: from c3smembership.data.model.base.c3smember.C3sMember import get_all [as 别名]
'datetime': datetime,
'date': date,
'new_members': [],
'num_members': 0,
'num_shares': 0,
'sum_shares': 0,
'new_shares': [],
'shares_paid_unapproved_count': 0,
'shares_paid_unapproved': [],
}
else: # if form not submitted, preload values
form.set_appstruct(appstruct)
# prepare: get information from the database
all_members = C3sMember.get_all()
new_members = []
lost_members = []
# now filter and count the afms and members
for member in all_members:
# if membership granted during time period
if member.membership_date >= start_date \
and member.membership_date <= end_date:
new_members.append(member)
# if membership was gained before the end of the time period and lost
# during the time period
if member.membership_date <= end_date \
and member.membership_loss_date is not None \
and member.membership_loss_date >= start_date \
and member.membership_loss_date <= end_date: