本文整理汇总了Python中models.Message.count方法的典型用法代码示例。如果您正苦于以下问题:Python Message.count方法的具体用法?Python Message.count怎么用?Python Message.count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Message
的用法示例。
在下文中一共展示了Message.count方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_must_retrieve_all_messages
# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import count [as 别名]
def test_must_retrieve_all_messages(self):
messages = Message().all()
initial_count = messages.count()
new_message = MessageFactory().create()
new_message.save()
messages = Message().all()
new_count = messages.count()
assert_equal(1, new_count - initial_count)
示例2: send_notification
# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import count [as 别名]
def send_notification(self, shop_code, product_code):
affected_messages = Message().fetch_by(shop_code=shop_code, product_code=product_code)
if affected_messages.count() == 0:
raise web.seeother("/")
product = Product(product_code).fetch()
shop = Shop(shop_code).fetch()
loyalty_code = self.generate_loyalty_code() # TODO: need to generate IN loop
reply_text = '%s is back in stock @ %s. Your loyalty code is %s' % (product.name, shop.name, loyalty_code)
response = util._send_sms([m['customer_number'] for m in affected_messages], reply_text )
if response is not None:
response_list = json.loads(response.content)['results']
for r in response_list:
if r['status'] == '0':
affected_messages.collection.update({'notified': False, 'product_code': product_code, 'shop_code': shop_code , 'customer_number': r['destination']}, {'$set': {'notified': True}})
return response.content