本文整理汇总了Python中stats.Stats.update_or_create方法的典型用法代码示例。如果您正苦于以下问题:Python Stats.update_or_create方法的具体用法?Python Stats.update_or_create怎么用?Python Stats.update_or_create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stats.Stats
的用法示例。
在下文中一共展示了Stats.update_or_create方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete_node
# 需要导入模块: from stats import Stats [as 别名]
# 或者: from stats.Stats import update_or_create [as 别名]
def delete_node(sender, **kwargs):
""" update user node count when a node is deleted """
node = kwargs['instance']
Stats.update_or_create(node.user, 'nodes')
# email notifications
#@receiver(node_status_changed)
#def notify_status_changed(sender, **kwargs):
# """ TODO: write desc """
# node = sender
# old_status = kwargs['old_status']
# new_status = kwargs['new_status']
# notification_type = EmailNotification.determine_notification_type(old_status, new_status, 'Node')
# EmailNotification.notify_users(notification_type, node)
#node_status_changed.connect(notify_status_changed)
示例2: delete_device
# 需要导入模块: from stats import Stats [as 别名]
# 或者: from stats.Stats import update_or_create [as 别名]
def delete_device(sender, **kwargs):
""" update user device count when a device is deleted """
device = kwargs['instance']
Stats.update_or_create(device.node.user, 'devices')
示例3: node_changed
# 需要导入模块: from stats import Stats [as 别名]
# 或者: from stats.Stats import update_or_create [as 别名]
def node_changed(sender, **kwargs):
""" update user node count when a node is saved """
created = kwargs['created']
node = kwargs['instance']
Stats.update_or_create(node.user, 'nodes')
示例4: new_device
# 需要导入模块: from stats import Stats [as 别名]
# 或者: from stats.Stats import update_or_create [as 别名]
def new_device(sender, **kwargs):
""" update user device count when a new device is added """
created = kwargs['created']
device = kwargs['instance']
if created:
Stats.update_or_create(device.node.user, 'devices')