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


Python Entity.get方法代码示例

本文整理汇总了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()
开发者ID:theswitch,项目名称:mhvdb2,代码行数:35,代码来源:test_members.py

示例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
开发者ID:cmrn,项目名称:mhvdb2,代码行数:10,代码来源:members.py

示例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()
开发者ID:theswitch,项目名称:mhvdb2,代码行数:11,代码来源:members.py

示例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()
开发者ID:kjnsn,项目名称:mhvdb2,代码行数:11,代码来源:members.py

示例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"
开发者ID:cmrn,项目名称:mhvdb2,代码行数:12,代码来源:tests_payments.py

示例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()
开发者ID:theswitch,项目名称:mhvdb2,代码行数:13,代码来源:test_entities.py

示例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
开发者ID:kjnsn,项目名称:mhvdb2,代码行数:22,代码来源:payments.py

示例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)
开发者ID:theswitch,项目名称:mhvdb2,代码行数:14,代码来源:test_entities.py

示例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')
开发者ID:kdmurray91,项目名称:mhvdb2,代码行数:16,代码来源:test_members.py

示例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()
开发者ID:kjnsn,项目名称:mhvdb2,代码行数:16,代码来源:payments.py

示例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()
开发者ID:cmrn,项目名称:mhvdb2,代码行数:18,代码来源:members.py

示例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)
开发者ID:theswitch,项目名称:mhvdb2,代码行数:20,代码来源:test_members.py

示例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
开发者ID:cmrn,项目名称:mhvdb2,代码行数:7,代码来源:entities.py

示例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
开发者ID:cmrn,项目名称:mhvdb2,代码行数:8,代码来源:members.py

示例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
开发者ID:cmrn,项目名称:mhvdb2,代码行数:7,代码来源:members.py


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