本文整理汇总了Python中models.Activity.reparent_all_my_session_objects方法的典型用法代码示例。如果您正苦于以下问题:Python Activity.reparent_all_my_session_objects方法的具体用法?Python Activity.reparent_all_my_session_objects怎么用?Python Activity.reparent_all_my_session_objects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Activity
的用法示例。
在下文中一共展示了Activity.reparent_all_my_session_objects方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: lazy_login
# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import reparent_all_my_session_objects [as 别名]
def lazy_login(sender, **kwargs):
request=kwargs['request']
user=kwargs['user']
if request.user.is_active:
#This is not at all where I want to put this code, but hopefully this should work for now more or less.
#Damn I need to debug things!
if Activity.objects.all_with_permission(request).count()==0:
#first create default activities
defActs=Activity.objects.filter(is_default=1)
for act in defActs:
act.pk=None
act.is_default=0
act.save(request)
Activity.reparent_all_my_session_objects(request.session, user)
ActivityRating.reparent_all_my_session_objects(request.session, user, request)
示例2: lazy_signup
# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import reparent_all_my_session_objects [as 别名]
def lazy_signup(sender, **kwargs):
request=kwargs['request']
user=kwargs['user']
Activity.reparent_all_my_session_objects(request.session, user)
ActivityRating.reparent_all_my_session_objects(request.session, user, request)