def bindingQQ(request): """ QQ 注册账号 :param request: :return: """ if request.method == 'POST': openid = request.POST.get('openid') figureurl_qq_1 = request.POST.get('figureurl_qq_1') nickname = request.POST.get('nickname') password = request.POST.get('password') password1 = request.POST.get('password1') email = request.POST.get('email') if password != password1: return render( request, 'pc/qqregister.html', { 'openid': openid, 'figureurl_qq_1': figureurl_qq_1, 'nickname': nickname, 'error': '两次密码不一致' }) else: User.objects.filter(email=email).exists() if User.objects.filter(email=email).exists(): return render( request, 'pc/qqregister.html', { 'openid': openid, 'figureurl_qq_1': figureurl_qq_1, 'nickname': nickname, 'error': '邮箱已存在' }) else: user = User() user.username = nickname user.email = email user.user_image = figureurl_qq_1 user.is_staff = False user.is_superuser = False user.is_active = True user.password = make_password(password1) user.save() qq = OAuthQQ() user_id = get_object_or_404(User, email=email).id qq.user_id = user_id msg = UserMessage() msg.user_id = user_id msg.to_user = User.objects.get(is_superuser=True) msg.message = '欢迎加入本站,在使用过程中有什么疑问,请联系管理员,Email: <a target="_blank" href="http://mail.qq.com/cgi-bin/qm_share?t=qm_mailme&email=iuzv5O3g4_T748rs7_Tt4OPk__Ok6eXn" style="text-decoration:none;">[email protected]</a>' msg.has_read = False msg.is_supper = True msg.save() qq.qq_openid = openid qq.nickname = nickname qq.figureurl_qq = figureurl_qq_1 qq.save() user = authenticate(request, username=email, password=password) login(request, user) return HttpResponseRedirect(reverse('home'))
def bindingQQ(request): """ QQ 注册账号 :param request: :return: """ if request.method == 'POST': openid = request.POST.get('openid') figureurl_qq_1 = request.POST.get('figureurl_qq_1') nickname = request.POST.get('nickname') password = request.POST.get('password') password1 = request.POST.get('password1') email = request.POST.get('email') if password != password1: return render( request, 'pc/qqregister.html', { 'openid': openid, 'figureurl_qq_1': figureurl_qq_1, 'nickname': nickname, 'error': '两次密码不一致' }) else: User.objects.filter(email=email).exists() if User.objects.filter(email=email).exists(): return render( request, 'pc/qqregister.html', { 'openid': openid, 'figureurl_qq_1': figureurl_qq_1, 'nickname': nickname, 'error': '邮箱已存在' }) else: user = User() user.username = nickname user.email = email user.user_image = figureurl_qq_1 user.password = make_password(password1) user.save() qq = OAuthQQ() user_id = get_object_or_404(User, email=email).id qq.user_id = user_id msg = UserMessage() msg.user_id = user_id msg.to_user = User.objects.get(username='******') msg.message = '欢迎加入本站,在使用过程中有什么疑问,请联系管理员' msg.has_read = False msg.is_supper = True msg.save() qq.qq_openid = openid qq.nickname = nickname qq.figureurl_qq = figureurl_qq_1 qq.save() user = authenticate(request, username=email, password=password) login(request, user) return HttpResponseRedirect(reverse('home'))
def my_callback_reply(sender, **kwargs): """ 评论通知 :param sender: :param kwargs: :return: """ try: message = UserMessage() message.user_id = kwargs['instance'].to_Parent_Comments_id message.ids = kwargs['instance'].forums_id message.to_user_id = kwargs['instance'].user.id message.has_read = False message.url =kwargs['instance'].url message.message = "你参与的 %s 帖子评论有人回复了,快去看看吧!"%kwargs['instance'].parent_comments.forums.title message.save() except Exception as e: pass