本文整理汇总了Python中mhvdb2.models.Entity类的典型用法代码示例。如果您正苦于以下问题:Python Entity类的具体用法?Python Entity怎么用?Python Entity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Entity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create
def test_create(self):
member_id = members.create(self.test_member.name,
self.test_member.email,
self.test_member.phone,
self.test_member.joined_date,
self.test_member.agreement_date)
member = Entity.get(Entity.id == member_id)
self.assertNotEqual(member.id, self.test_member.id)
self.assertEqual(member.name, self.test_member.name)
self.assertEqual(member.email, self.test_member.email)
self.assertEqual(member.phone, self.test_member.phone)
self.assertEqual(member.joined_date, self.test_member.joined_date)
self.assertEqual(member.agreement_date, self.test_member.agreement_date)
member.delete_instance()
member_id = members.create(self.test_member.name,
self.test_member.email,
self.test_member.phone,
None,
self.test_member.agreement_date)
member = Entity.get(Entity.id == member_id)
self.assertEqual(member.joined_date, date.today())
member.delete_instance()
member_id = members.create(self.test_member.name,
self.test_member.email,
self.test_member.phone,
self.test_member.joined_date,
None)
member = Entity.get(Entity.id == member_id)
self.assertEqual(member.agreement_date, date.today())
member.delete_instance()
示例2: setUp
def setUp(self):
self.test_entity = Entity()
self.test_entity.is_member = False
self.test_entity.name = "Jane Smith"
self.test_entity.email = "[email protected]"
self.test_entity.phone = "+61 (02) 1234 5678"
self.test_entity.save()
示例3: create
def create(name, email, phone):
entity = Entity()
entity.is_member = False
entity.name = name
entity.email = email
entity.phone = phone
entity.is_keyholder = False
entity.save()
return entity.id
示例4: authenticate_token
def authenticate_token(token):
try:
member = Entity.get(Entity.token == token)
if (member.token_expiry > datetime.now()):
return member
except:
pass
return None # no such token for member, or token is expired
示例5: create
def create(name, email, phone):
member = Entity()
member.is_member = True
member.joined_date = date.today()
member.name = name
member.email = email
member.phone = phone
member.agreement_date = date.today()
return member.save()
示例6: update
def update(name, email, phone, member=None):
if member is None:
member = Entity.get(Entity.email == email)
member.name = name
member.email = email
member.phone = phone
member.agreement_date = date.today()
return member.save()
示例7: update
def update(member_id, name, email, phone, joined_date=None, agreement_date=None):
member = Entity.get((Entity.id == member_id) & Entity.is_member)
member.name = name
member.email = email
member.phone = phone
member.joined_date = joined_date
member.agreement_date = agreement_date
return member.save()
示例8: setUp
def setUp(self):
self.type = 2
self.email = "[email protected]"
self.entity = Entity.get(Entity.id == entities.create("Jane Doe", self.email, ""))
self.amount = 1234
self.entity = self.entity
self.method = 0
self.is_donation = True
self.notes = "For services rendered"
self.reference = "yx92s3"
示例9: create
def create(name, email, phone, joined_date=None, agreement_date=None):
if joined_date is None:
joined_date = date.today()
if agreement_date is None:
agreement_date = date.today()
member = Entity()
member.is_member = True
member.name = name
member.email = email
member.phone = phone
member.joined_date = joined_date
member.agreement_date = agreement_date
member.save()
return member.id
示例10: test_create
def test_create(self):
entity_id = entities.create(self.test_entity.name,
self.test_entity.email,
self.test_entity.phone)
entity = Entity.get(Entity.id == entity_id)
self.assertNotEqual(entity.id, self.test_entity.id)
self.assertEqual(entity.name, self.test_entity.name)
self.assertEqual(entity.email, self.test_entity.email)
self.assertEqual(entity.phone, self.test_entity.phone)
entity.delete_instance()
示例11: setUp
def setUp(self):
self.test_member = Entity()
self.test_member.is_member = True
self.test_member.name = "Jane Smith"
self.test_member.email = "[email protected]"
self.test_member.phone = "+61 (02) 1234 5678"
self.test_member.joined_date = date.today()-timedelta(days=1)
self.test_member.agreement_date = date.today()
self.test_member.save()
self.joined_date = "2014-12-24"
self.agreement_date = "2014-12-25"
示例12: validate
def validate(amount, email, method, type, notes, reference):
errors = []
if not amount or not re.match("^[0-9]*(\.[0-9]{2}|\.[0-9]|)$", amount):
errors.append("Sorry, you need to provide a valid amount.")
if not re.match("[^@\s][email protected][^@\s]+", email):
errors.append("Sorry, you need to provide a valid email address.")
else: # Valid email, so check that they're a member
try:
Entity.get(Entity.email == email)
except DoesNotExist:
errors.append("Sorry, you need to provide a valid member's email address.")
if not type or not type.isdigit() or int(type) > 2:
errors.append("Sorry, you need to provide a valid payment type.")
if not method or not method.isdigit() or int(method) > 2:
errors.append("Sorry, you need to provide a valid payment method.")
if not reference:
errors.append("Sorry, you need to provide a reference.")
return errors
示例13: test_update
def test_update(self):
new_name = "Joe Flanders"
new_email = "[email protected]"
new_phone = "(04) 9876 5432"
entities.update(self.test_entity.id,
new_name,
new_email,
new_phone)
entity = Entity.get(Entity.id == self.test_entity.id)
self.assertEqual(entity.name, new_name)
self.assertEqual(entity.email, new_email)
self.assertEqual(entity.phone, new_phone)
示例14: test_active_member
def test_active_member(self):
self.assertTrue(self.test_member.active_member(),
'member agreement is current')
new_agreement_date = date.today()-timedelta(days=500)
members.update(self.test_member.id,
self.test_member.name,
self.test_member.email,
self.test_member.phone,
self.test_member.joined_date,
new_agreement_date,
self.test_member.is_keyholder)
member = Entity.get(Entity.id == self.test_member.id)
self.assertFalse(member.active_member(), 'member agreement not current')
示例15: create
def create(amount, email, method, type, notes, reference):
# Create payment
payment = Payment()
payment.time = datetime.now()
payment.entity = Entity.get(Entity.email == email)
payment.amount = amount
payment.source = method
payment.is_donation = type != 0
payment.notes = notes
if method == 0: # Bank transfer
payment.bank_reference = reference
payment.pending = True
payment.save()