本文整理汇总了Python中models.Activity.log_activity方法的典型用法代码示例。如果您正苦于以下问题:Python Activity.log_activity方法的具体用法?Python Activity.log_activity怎么用?Python Activity.log_activity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Activity
的用法示例。
在下文中一共展示了Activity.log_activity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: login_User
# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import log_activity [as 别名]
def login_User(request):
if request.method == "POST":
username = request.POST['username']
password = request.POST['password']
user = authenticate(username=username, password=password)
if user != None:
if user.is_active == True:
userprofile = user.userprofile
login(request, user)
messages.success(request, 'Welcome, %s!' % (username))
Activity.log_activity("ACTIVITY_LOGIN", user.userprofile)
next_url = request.GET.get('next', URL_HOME)
if "//" in next_url and re.match(r'[^\?]*//', next_url):
next_url = settings.LOGIN_REDIRECT_URL
return redirect(next_url)
else:
messages.error(request, "You haven't activated your account yet. Please check your email.")
else:
messages.error(request, 'Invalid Login credentials. Please try again.')
next_path = request.GET.get('next', URL_HOME)
form = AuthenticationForm()
return render_to_response(HTML_LOGIN, {'form':form}, RequestContext(request, {'next': next_path}))
示例2: logout_User
# 需要导入模块: from models import Activity [as 别名]
# 或者: from models.Activity import log_activity [as 别名]
def logout_User(request):
# Update last_logout date field
user = get_object_or_404(UserProfile, pk=request.user.userprofile.id)
user.last_logout = datetime.now()
user.save()
Activity.log_activity("ACTIVITY_LOGOUT", request.user.userprofile)
messages.success(request, "See you next time!")
logout(request)
return redirect(URL_HOME)