def active_user(request, token): #激活验证 try: username = token_confirm.confirm_validate_token(token) except: username = token_confirm.remove_validate_token(token) users = User.objects.filter(username=username) for user in users: if user.is_active==False: user.delete() return render(request, 'pc/message.html', {'message': u'对不起,验证链接已经过期,请重新<a href=\"' + unicode(settings.DOMAIN) + u'/register\">注册</a>'}) else: return render(request, 'pc/message.html', {'message': u'此账号已经验证过,请重新<a href=\"' + unicode(settings.DOMAIN) + u'/register\">注册</a>'}) try: user = User.objects.get(username=username) except User.DoesNotExist: return render(request, 'pc/message.html', {'message': u'对不起,您所验证的用户不存在,请重新<a href=\"/register\">注册</a>'}) user.is_active = True user.save() msg = UserMessage() msg.user=user msg.to_user =User.objects.get(is_superuser=True) msg.message = '欢迎加入本站,在使用过程中有什么疑问,请联系管理员' msg.has_read = False msg.is_supper = True msg.save() message = u'验证成功,请进行<a href=\"' + unicode(settings.DOMAIN) + u'/login\">登录</a>操作' return render(request, 'pc/message.html', {'message':message})
def active_user(request, token): #激活验证 try: username = token_confirm.confirm_validate_token(token) except: username = token_confirm.remove_validate_token(token) users = User.objects.filter(username=username) for user in users: if user.is_active == False: user.delete() return render( request, 'pc/message.html', { 'message': u'对不起,验证链接已经过期,请重新<a href=\"' + unicode(settings.DOMAIN) + u'/signup\">注册</a>' }) else: return render( request, 'pc/message.html', { 'message': u'此账号已经验证过,请重新<a href=\"' + unicode(settings.DOMAIN) + u'/signup\">注册</a>' }) try: user = User.objects.get(username=username) except User.DoesNotExist: return render(request, 'pc/message.html', {'message': u"对不起,您所验证的用户不存在,请重新注册"}) user.is_active = True user.save() message = u'验证成功,请进行<a href=\"' + unicode( settings.DOMAIN) + u'/login\">登录</a>操作' return render(request, 'pc/message.html', {'message': message})