def get(self, request):
        qq = request.GET['qq']
        user = User.objects.filter(qq__exact = qq).first()
        if user is None:
            msg = {
                "status" : 'error',
                "msg" : 'user not exist'
            }
        else:
            if user.status == 1:
                msg = {
                    "status" : 'error',
                    "msg" : 'user already activated'
                }
            else:
                with open(BASE_DIR + "/api/mail_template/activate.html", 'rt') as mail_template:
                    template = mail_template.read()
                token = new_token(user, 'activate').get_token()
                link = "http://www.qjob.social/api/activate/?token=" + token
                email_content = template % ('user', user.qq, link)


                start_mail_thread(
                    'Qjob account activate',
                    email_content,
                    email_address,
                    ['*****@*****.**' % user.qq]
                )

                msg = {
                    "status" : 'success',
                    "msg" : 'email is delivered'
                }
        return JsonResponse(msg)
示例#2
0
    def get(self, request):
        groupId = request.GET['id']
        owner = GroupAdmin.objects.filter(groupId__exact= groupId, userType__exact = 1).first()
        if owner is None:
            msg = {
                "status" : 'error',
                "msg" : 'group not exist'
            }
        else:
            with open(BASE_DIR + "/api/mail_template/recover.html", 'rt') as mail_template:
                template = mail_template.read()
            token = new_token(owner, 'recover')
            token.id = groupId
            token = token.get_token()
            link = "http://www.qjob.social/api/group/recover/?token=" + token
            email_content = template % ('owner', owner.qq, link)

            start_mail_thread(
                'Qjob account recover',
                email_content,
                email_address,
                ['*****@*****.**' % owner.qq]
            )

            msg = {
                "status" : 'success',
                "msg" : 'email is delivered'
            }
        return JsonResponse(msg)
示例#3
0
    def get(self, request):
        uf = qqForm(request.GET)
        if not uf.is_valid():
            return JsonResponse({
                "status": "error",
                "msg": "邮件发送失败"
            })

        qq = uf.cleaned_data["qq"]
        user = User.objects.filter(qq__exact= qq).first()
        if user is None:
            msg = {
                "status" : 'error',
                "msg" : 'user not exist'
            }
        else:
            with open(BASE_DIR + "/api/mail_template/recover.html", 'rt', encoding='utf-8') as mail_template:
                template = mail_template.read()
            token = new_token(user, 'recover').get_token()
            link = "%s://%s/#/new_pwd/%s" %(protocol, domain, token)
            email_content = template % (user.qq, link, user_email, user_group)

            start_mail_thread(
                'Qjob账户密码重置',
                email_content,
                ['*****@*****.**' % user.qq]
            )

            msg = {
                "status" : 'success',
                "msg" : '邮件已发送,请注意查收'
            }
        return JsonResponse(msg)
 def post(self, request):
     check = CheckRequest(request)
     if not check.user:
         return JsonResponse({
             "status": "error",
             "msg": "User not logined"
         })
     uf = PostForm(check.jsonForm)
     if uf.is_valid():
         resume = Resume(
             userEmail = uf.cleaned_data['email'],
             groupId = uf.cleaned_data['groupId'],
             qq = uf.cleaned_data['qq'],
             username = uf.cleaned_data['username'],
             sex = uf.cleaned_data['sex'],
             age = uf.cleaned_data['age'],
             yearsOfWorking = uf.cleaned_data['yearsOfWorking'],
             school = uf.cleaned_data['school'],
             education = uf.cleaned_data['education'],
             content = uf.cleaned_data['content'],
             display = uf.cleaned_data['display']
         )
         resume.save()
         if resume.id:
             with open(BASE_DIR + "/api/mail_template/remind.html", 'rt') as mail_template:
                 template = mail_template.read()
             admins = GroupAdmin.objects.filter(groupId = resume.groupId,
                                                 status= 1).all()
             link = "http://www.qjob.social/api/group/resume_list/"
             email_content = template % (resume.qq, link)
             start_mail_thread(        
                 'Qjob new resume remind', 
                 email_content,
                 email_address,
                 ['*****@*****.**' % admin.qq for admin in admins]
                 )
             return JsonResponse({
                 "status" : 'success',
                 'msg' : "already notifyied admins"
                 })
         else:
             return JsonResponse({
                 "status" : 'error',
                 'msg' : "Post error"
                 })
     else:
         return JsonResponse({
             "status": "error",
             "msg": "From error: %s" % uf.errors
         })
示例#5
0
    def get(self, request):
        uf = ActivaterForm(request.GET)
        if not uf.is_valid():
            return JsonResponse({
                "status": "error",
                "msg": "激活邮件发送失败,表单有误"
            })

        groupId = uf.cleaned_data['groupId']
        qq = uf.cleaned_data['qq']
        admin = GroupAdmin.objects.filter(groupId__exact = groupId, qq__exact=qq).first()
        if admin is None:
            msg = {
                "status" : 'error',
                "msg" : 'Admin not exist'
            }
        else:
            if admin.status == 1:
                msg = {
                    "status" : 'error',
                    "msg" : 'group owner already activated'
                }
            else:
                group = Group.objects.filter(groupId__exact=groupId).first()
                if not group:
                    return JsonResponse({
                        "status" : 'error',
                        "msg" : '群ID不存在'
                    })
                with open(BASE_DIR + "/api/mail_template/admin_activate.html", 'rt', encoding='utf-8') as mail_template:
                    template = mail_template.read()
                token = new_token(admin, 'activate')
                token = token.get_token()
                link = "%s://%s/api/group/activate/?token=%s" %(protocol, domain, token)
                email_content = template % (group.groupName, groupId, admin.qq, link, admin_email, admin_group)


                start_mail_thread(
                    'Qjob管理员账户激活',
                    email_content,
                    ['*****@*****.**' % admin.qq]
                )

                msg = {
                    "status" : 'success',
                    "msg" : 'email is delivered'
                }
        return JsonResponse(msg)
示例#6
0
    def get(self, request):
        uf = ActivaterForm(request.GET)
        if not uf.is_valid():
            return JsonResponse({
                "status": "error",
                "msg": "激活邮件发送失败,表单有误"
            })

        groupId = uf.cleaned_data['groupId']
        qq = uf.cleaned_data['qq']
        admin = GroupAdmin.objects.filter(groupId__exact = groupId, qq__exact=qq).first()
        if admin is None:
            msg = {
                "status" : 'error',
                "msg" : 'Admin not exist'
            }
        else:
            if admin.status == 1:
                msg = {
                    "status" : 'error',
                    "msg" : 'group owner already activated'
                }
            else:
                group = Group.objects.filter(groupId__exact=groupId).first()
                if not group:
                    return JsonResponse({
                        "status" : 'error',
                        "msg" : '群ID不存在'
                    })
                with open(BASE_DIR + "/api/mail_template/admin_activate.html", 'rt', encoding='utf-8') as mail_template:
                    template = mail_template.read()
                token = new_token(admin, 'activate')
                token = token.get_token()
                link = "%s://%s/api/group/activate/?token=%s" %(protocol, domain, token)
                email_content = template % (group.groupName, admin.qq, link, admin_email, admin_group)


                start_mail_thread(
                    'Qjob管理员账户激活',
                    email_content,
                    ['*****@*****.**' % admin.qq]
                )

                msg = {
                    "status" : 'success',
                    "msg" : 'email is delivered'
                }
        return JsonResponse(msg)
示例#7
0
    def get(self, request):
        uf = RecoverForm(request.GET)
        if not uf.is_valid():
            return JsonResponse({
                "status": "error",
                "msg": "邮件发送失败"
            })

        groupId = uf.cleaned_data["groupId"]
        qq = uf.cleaned_data["qq"]
        admin = GroupAdmin.objects.filter(groupId__exact=groupId, qq__exact=qq).first()
        if admin is None:
            msg = {
                "status" : 'error',
                "msg" : '群ID或管理员QQ不存在'
            }
        else:
            group = Group.objects.filter(groupId__exact=groupId).first()
            if not group:
                return JsonResponse({
                    "status" : 'error',
                    "msg" : '群ID不存在'
                })
            with open(BASE_DIR + "/api/mail_template/admin_recover.html", 'rt', encoding='utf-8') as mail_template:
                template = mail_template.read()
            token = new_token(admin, 'recover')
            token = token.get_token()
            link = "%s://%s/#/group/new_pwd/%s" %(protocol, domain, token)
            email_content = template % (group.groupName, groupId, admin.qq, link, admin_email, admin_group)

            start_mail_thread(
                'Qjob管理员账户密码重置',
                email_content,
                ['*****@*****.**' % admin.qq]
            )

            msg = {
                "status" : 'success',
                "msg" : 'email is delivered'
            }
        return JsonResponse(msg)
示例#8
0
    def get(self, request):
        uf = RecoverForm(request.GET)
        if not uf.is_valid():
            return JsonResponse({
                "status": "error",
                "msg": "邮件发送失败"
            })

        groupId = uf.cleaned_data["groupId"]
        qq = uf.cleaned_data["qq"]
        admin = GroupAdmin.objects.filter(groupId__exact=groupId, qq__exact=qq).first()
        if admin is None:
            msg = {
                "status" : 'error',
                "msg" : '群ID或管理员QQ不存在'
            }
        else:
            group = Group.objects.filter(groupId__exact=groupId).first()
            if not group:
                return JsonResponse({
                    "status" : 'error',
                    "msg" : '群ID不存在'
                })
            with open(BASE_DIR + "/api/mail_template/admin_recover.html", 'rt', encoding='utf-8') as mail_template:
                template = mail_template.read()
            token = new_token(admin, 'recover')
            token = token.get_token()
            link = "%s://%s/#/group/new_pwd/%s" %(protocol, domain, token)
            email_content = template % (group.groupName, admin.qq, link, admin_email, admin_group)

            start_mail_thread(
                'Qjob管理员账户密码重置',
                email_content,
                ['*****@*****.**' % admin.qq]
            )

            msg = {
                "status" : 'success',
                "msg" : 'email is delivered'
            }
        return JsonResponse(msg)
 def post(self, request):
     check = CheckRequest(request)
     if not check.user:
         return JsonResponse({"status": "error", "msg": "User not logined"})
     uf = PostForm(check.jsonForm)
     if uf.is_valid():
         resume = Resume(userEmail=uf.cleaned_data['email'],
                         groupId=uf.cleaned_data['groupId'],
                         qq=uf.cleaned_data['qq'],
                         username=uf.cleaned_data['username'],
                         sex=uf.cleaned_data['sex'],
                         age=uf.cleaned_data['age'],
                         yearsOfWorking=uf.cleaned_data['yearsOfWorking'],
                         school=uf.cleaned_data['school'],
                         education=uf.cleaned_data['education'],
                         content=uf.cleaned_data['content'],
                         display=uf.cleaned_data['display'])
         resume.save()
         if resume.id:
             with open(BASE_DIR + "/api/mail_template/remind.html",
                       'rt') as mail_template:
                 template = mail_template.read()
             admins = GroupAdmin.objects.filter(groupId=resume.groupId,
                                                status=1).all()
             link = "http://www.qjob.social/api/group/resume_list/"
             email_content = template % (resume.qq, link)
             start_mail_thread('Qjob new resume remind', email_content,
                               email_address,
                               ['*****@*****.**' % admin.qq for admin in admins])
             return JsonResponse({
                 "status": 'success',
                 'msg': "already notifyied admins"
             })
         else:
             return JsonResponse({"status": 'error', 'msg': "Post error"})
     else:
         return JsonResponse({
             "status": "error",
             "msg": "From error: %s" % uf.errors
         })
示例#10
0
 def post(self, request):
     check = CheckRequest(request)
     if not check.user:
         return JsonResponse({
             "status": "error",
             "msg": "User not logined"
         })
     uf = PostForm(check.jsonForm)
     if uf.is_valid():
         group = Group.objects.filter(groupId__exact = uf.cleaned_data['groupId']).first()
         groupName = ""
         if group:
             groupName = group.groupName
         checkResume = Resume.objects.filter(groupId__exact = uf.cleaned_data['groupId'], qq__exact=uf.cleaned_data['qq']).first()
         if checkResume:
             return JsonResponse({
                 "status": "success",
                 "code":30003,
                 "msg": successCode[30003],
                 'count': 1,
                 'data':{
                     'id': checkResume.id,
                     'jobTitle': checkResume.jobTitle,
                     'email': checkResume.userEmail,
                     "groupId": checkResume.groupId,
                     "groupName": groupName,
                     "username": checkResume.username,
                     "qq": checkResume.qq,
                     'sex': checkResume.sex,
                     'age': checkResume.age,
                     'yearsOfWorking': checkResume.yearsOfWorking,
                     'school': checkResume.school,
                     'education': checkResume.education,
                     "lastDate": checkResume.lastDate,
                     "content": checkResume.content,
                     'display': checkResume.display,
                     "status": checkResume.status
                 }
             })
         resume = Resume(
             jobTitle= uf.cleaned_data['jobTitle'],
             userEmail = uf.cleaned_data['email'],
             groupId = uf.cleaned_data['groupId'],
             qq = uf.cleaned_data['qq'],
             username = uf.cleaned_data['username'],
             sex = uf.cleaned_data['sex'],
             age = uf.cleaned_data['age'],
             yearsOfWorking = uf.cleaned_data['yearsOfWorking'],
             school = uf.cleaned_data['school'],
             education = uf.cleaned_data['education'],
             content = uf.cleaned_data['content'],
             display = uf.cleaned_data['display']
         )
         resume.save()
         if resume.id:
             responseCode = 30000
             try:
                 with open(BASE_DIR + "/api/mail_template/remind.html", 'rt', encoding='utf-8') as mail_template:
                     template = mail_template.read()
                 admins = GroupAdmin.objects.filter(groupId = resume.groupId,
                                                     status= 1).all()
                 link = "%s://%s/#/group/resume/%s" % (protocol, domain, str(resume.id))
                 email_content = template % (groupName, resume.username, resume.qq, link, admin_email, admin_group)
                 start_mail_thread(
                     'Qjob新用户入群',
                     email_content,
                     ['*****@*****.**' % admin.qq for admin in admins]
                     )
             except:
                 responseCode = 30001
             return JsonResponse({
                 "status": 'success',
                 'msg': successCode[responseCode],
                 'code': responseCode,
                 'count': 1,
                 'data':{
                     'id': resume.id,
                     'jobTitle': resume.jobTitle,
                     'email': resume.userEmail,
                     "groupId": resume.groupId,
                     "groupName": groupName,
                     "username": resume.username,
                     "qq": resume.qq,
                     'sex': resume.sex,
                     'age': resume.age,
                     'yearsOfWorking': resume.yearsOfWorking,
                     'school': resume.school,
                     'education': resume.education,
                     "lastDate": resume.lastDate,
                     "content": resume.content,
                     'display': resume.display,
                     "status": resume.status
                 }
             })
         else:
             return JsonResponse({
                 "status" : 'error',
                 'msg' : "Save error"
                 })
     else:
         return JsonResponse({
             "status": "error",
             "msg": "From error: %s" % uf.errors
         })
示例#11
0
 def post(self, request):
     check = CheckRequest(request)
     if not check.user:
         return JsonResponse({"status": "error", "msg": "User not logined"})
     uf = PostForm(check.jsonForm)
     if uf.is_valid():
         group = Group.objects.filter(
             groupId__exact=uf.cleaned_data['groupId']).first()
         groupName = ""
         if group:
             groupName = group.groupName
         checkResume = Resume.objects.filter(
             groupId__exact=uf.cleaned_data['groupId'],
             qq__exact=uf.cleaned_data['qq']).first()
         if checkResume:
             return JsonResponse({
                 "status": "success",
                 "code": 30003,
                 "msg": successCode[30003],
                 'count': 1,
                 'data': {
                     'id': checkResume.id,
                     'jobTitle': checkResume.jobTitle,
                     'email': checkResume.userEmail,
                     "groupId": checkResume.groupId,
                     "groupName": groupName,
                     "username": checkResume.username,
                     "qq": checkResume.qq,
                     'sex': checkResume.sex,
                     'age': checkResume.age,
                     'yearsOfWorking': checkResume.yearsOfWorking,
                     'school': checkResume.school,
                     'education': checkResume.education,
                     "lastDate": checkResume.lastDate,
                     "content": checkResume.content,
                     'display': checkResume.display,
                     "status": checkResume.status
                 }
             })
         resume = Resume(jobTitle=uf.cleaned_data['jobTitle'],
                         userEmail=uf.cleaned_data['email'],
                         groupId=uf.cleaned_data['groupId'],
                         qq=uf.cleaned_data['qq'],
                         username=uf.cleaned_data['username'],
                         sex=uf.cleaned_data['sex'],
                         age=uf.cleaned_data['age'],
                         yearsOfWorking=uf.cleaned_data['yearsOfWorking'],
                         school=uf.cleaned_data['school'],
                         education=uf.cleaned_data['education'],
                         content=uf.cleaned_data['content'],
                         display=uf.cleaned_data['display'])
         resume.save()
         if resume.id:
             responseCode = 30000
             try:
                 with open(BASE_DIR + "/api/mail_template/remind.html",
                           'rt',
                           encoding='utf-8') as mail_template:
                     template = mail_template.read()
                 admins = GroupAdmin.objects.filter(groupId=resume.groupId,
                                                    status=1).all()
                 link = "%s://%s/#/group/resume/%s" % (protocol, domain,
                                                       str(resume.id))
                 email_content = template % (groupName, resume.username,
                                             resume.qq, link, admin_email,
                                             admin_group)
                 start_mail_thread(
                     'Qjob新用户入群', email_content,
                     ['*****@*****.**' % admin.qq for admin in admins])
             except:
                 responseCode = 30001
             return JsonResponse({
                 "status": 'success',
                 'msg': successCode[responseCode],
                 'code': responseCode,
                 'count': 1,
                 'data': {
                     'id': resume.id,
                     'jobTitle': resume.jobTitle,
                     'email': resume.userEmail,
                     "groupId": resume.groupId,
                     "groupName": groupName,
                     "username": resume.username,
                     "qq": resume.qq,
                     'sex': resume.sex,
                     'age': resume.age,
                     'yearsOfWorking': resume.yearsOfWorking,
                     'school': resume.school,
                     'education': resume.education,
                     "lastDate": resume.lastDate,
                     "content": resume.content,
                     'display': resume.display,
                     "status": resume.status
                 }
             })
         else:
             return JsonResponse({"status": 'error', 'msg': "Save error"})
     else:
         return JsonResponse({
             "status": "error",
             "msg": "From error: %s" % uf.errors
         })