當前位置: 首頁>>代碼示例>>Python>>正文


Python models.Entity類代碼示例

本文整理匯總了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()
開發者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


注:本文中的mhvdb2.models.Entity類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。