Beispiel #1
0
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})
Beispiel #2
0
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'))
Beispiel #3
0
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'))
Beispiel #4
0
def my_callback(sender, **kwargs):
    """
    评论通知
    :param sender:
    :param kwargs:
    :return:
    """
    message = UserMessage()
    message.user=kwargs['instance'].forums.authors
    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'].forums.title
    message.save()
Beispiel #5
0
def my_callback_reply(sender, **kwargs):
    """
    评论通知
    :param sender:
    :param kwargs:
    :return:
    """
    message = UserMessage()
    message.user = kwargs['instance'].to_uids
    message.ids = kwargs['instance'].aomments_id.article.id
    message.to_user = kwargs['instance'].user
    message.has_read = False
    message.url =kwargs['instance'].url
    message.message = "你参与的 %s 文章评论有人回复了,快去看看吧!"%kwargs['instance'].aomments_id.article.title
    message.save()
Beispiel #6
0
def my_callback_reply(sender, **kwargs):
    """
    评论通知
    :param sender:
    :param kwargs:
    :return:
    """
    message = UserMessage()

    message.user=kwargs['instance'].to_Parent_Comments
    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'].forums.title
    message.save()