• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.Entity类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mhvdb2.models.Entity的典型用法代码示例。如果您正苦于以下问题:Python Entity类的具体用法?Python Entity怎么用?Python Entity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Entity类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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()
开发者ID:theswitch,项目名称:mhvdb2,代码行数:33,代码来源:test_members.py


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


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


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


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


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


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


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


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


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


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


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


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


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


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


示例16: update

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,代码行数:16,代码来源:members.py


示例17: test_update

 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,代码行数:18,代码来源:test_members.py


示例18: get

def get(entity_id):
    try:
        return Entity.get(Entity.id == entity_id)
    except DoesNotExist:
        return None
开发者ID:cmrn,项目名称:mhvdb2,代码行数:5,代码来源:entities.py


示例19: create_token

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,代码行数:6,代码来源:members.py


示例20: get

def get(member_id):
    try:
        return Entity.get((Entity.id == member_id) & Entity.is_member)
    except DoesNotExist:
        return None
开发者ID:cmrn,项目名称:mhvdb2,代码行数:5,代码来源:members.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils._函数代码示例发布时间:2022-05-27
下一篇:
Python utils.error_response函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap