本文整理汇总了Python中mhvdb2.models.Entity.get方法的典型用法代码示例。如果您正苦于以下问题:Python Entity.get方法的具体用法?Python Entity.get怎么用?Python Entity.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mhvdb2.models.Entity
的用法示例。
在下文中一共展示了Entity.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create
# 需要导入模块: from mhvdb2.models import Entity [as 别名]
# 或者: from mhvdb2.models.Entity import get [as 别名]
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: authenticate_token
# 需要导入模块: from mhvdb2.models import Entity [as 别名]
# 或者: from mhvdb2.models.Entity import get [as 别名]
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
示例3: update
# 需要导入模块: from mhvdb2.models import Entity [as 别名]
# 或者: from mhvdb2.models.Entity import get [as 别名]
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()
示例4: update
# 需要导入模块: from mhvdb2.models import Entity [as 别名]
# 或者: from mhvdb2.models.Entity import get [as 别名]
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()
示例5: setUp
# 需要导入模块: from mhvdb2.models import Entity [as 别名]
# 或者: from mhvdb2.models.Entity import get [as 别名]
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"
示例6: test_create
# 需要导入模块: from mhvdb2.models import Entity [as 别名]
# 或者: from mhvdb2.models.Entity import get [as 别名]
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()
示例7: validate
# 需要导入模块: from mhvdb2.models import Entity [as 别名]
# 或者: from mhvdb2.models.Entity import get [as 别名]
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
示例8: test_update
# 需要导入模块: from mhvdb2.models import Entity [as 别名]
# 或者: from mhvdb2.models.Entity import get [as 别名]
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)
示例9: test_active_member
# 需要导入模块: from mhvdb2.models import Entity [as 别名]
# 或者: from mhvdb2.models.Entity import get [as 别名]
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')
示例10: create
# 需要导入模块: from mhvdb2.models import Entity [as 别名]
# 或者: from mhvdb2.models.Entity import get [as 别名]
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()
示例11: update
# 需要导入模块: from mhvdb2.models import Entity [as 别名]
# 或者: from mhvdb2.models.Entity import get [as 别名]
def update(member_id, name, email, phone, joined_date=None, agreement_date=None,
is_keyholder=False):
member = Entity.get((Entity.id == member_id) & Entity.is_member)
member.name = name
member.email = email
member.phone = phone
if joined_date is not None:
member.joined_date = joined_date
if agreement_date is not None:
member.agreement_date = agreement_date
if is_keyholder is None:
member.is_keyholder = False
else:
member.is_keyholder = is_keyholder
return member.save()
示例12: test_update
# 需要导入模块: from mhvdb2.models import Entity [as 别名]
# 或者: from mhvdb2.models.Entity import get [as 别名]
def test_update(self):
new_name = "Joe Flanders"
new_email = "[email protected]"
new_phone = "(04) 9876 5432"
new_joined_date = date.today()-timedelta(days=7)
new_agreement_date = date.today()-timedelta(days=6)
members.update(self.test_member.id,
new_name,
new_email,
new_phone,
new_joined_date,
new_agreement_date)
member = Entity.get(Entity.id == self.test_member.id)
self.assertEqual(member.name, new_name)
self.assertEqual(member.email, new_email)
self.assertEqual(member.phone, new_phone)
self.assertEqual(member.joined_date, new_joined_date)
self.assertEqual(member.agreement_date, new_agreement_date)
示例13: get
# 需要导入模块: from mhvdb2.models import Entity [as 别名]
# 或者: from mhvdb2.models.Entity import get [as 别名]
def get(entity_id):
try:
return Entity.get(Entity.id == entity_id)
except DoesNotExist:
return None
示例14: create_token
# 需要导入模块: from mhvdb2.models import Entity [as 别名]
# 或者: from mhvdb2.models.Entity import get [as 别名]
def create_token(email):
member = Entity.get((Entity.email == email) & Entity.is_member)
member.token = __generate_token()
member.token_expiry = datetime.now() + timedelta(hours=24)
member.save()
return member.token
示例15: get
# 需要导入模块: from mhvdb2.models import Entity [as 别名]
# 或者: from mhvdb2.models.Entity import get [as 别名]
def get(member_id):
try:
return Entity.get((Entity.id == member_id) & Entity.is_member)
except DoesNotExist:
return None