Ejemplo n.º 1
0
    def get(self):
        user_id = session.get('user_id')
        if not user_id:
            if not session.get("account_id"):
                return success(res={'error_code': 4001, 'msg': '未登入'})
            else:
                user_id = request.args.get("user_id")

        obj = Account.get(id=user_id)

        if obj:
            rn = Resume.objects(accounts=obj).first()
            if not rn:
                return success(res={'error_code': 4001, 'msg': '下载失败'})

            file_key = rn.file_key
            if file_key:
                response = make_response(send_file(file_key))
                response.headers[
                    "Content-Disposition"] = "attachment; filename={0};".format(
                        rn.file_name)
                return response
            else:
                return success(res={'error_code': 4001, 'msg': '下载失败'})
        else:
            return success(res={'error_code': 4001, 'msg': '下载失败'})
Ejemplo n.º 2
0
    def post(self):
        post = request.form
        tel = post.get("tel")
        if not tel:
            return success(res={'r': 1, 'error_code': 4006, 'msg': '手机号不能为空'})

        if not AdminAccount.objects(tel=tel):
            return success(res={'r': 1, 'error_code': 4006, 'msg': '用户不存在'})

        key = model.CHECKCODE_KEY.format(tel=tel)
        code = cache.get(key)
        if not code:
            code = random.randint(100000, 999999)
            cache.incr(key, code)
            cache.expire(key, 300)

        if config.get("DEBUG"):
            print code, "CODEEE"
            ret = True
        else:
            ret = alidayu_tool.send_code(phone=tel, num=str(code))

        if ret:
            return success(res={})
        else:
            return success(res={'error_code': 4001, 'msg': u'验证码发送失败'})
Ejemplo n.º 3
0
    def post(self):
        post = request.form
        tel = post.get("tel")
        passwd = post.get('passwd')

        if not tel or not passwd:
            return success(res={'error_code': 4001, 'msg': '字段缺失'})

        if len(passwd) < 6:
            return success(res={'error_code': 4001, 'msg': "密码格式错误"})

        rn = Account.objects(tel=tel).first()

        if rn:
            passwd = str(passwd)
            hash_passwd = hmac.new(passwd)
            hash_passwd.update(passwd[1:5])

            if hash_passwd.hexdigest() == rn.password:
                session['user_id'] = rn.id
                return success()
            else:
                return success(res={'error_code': 4001, 'msg': '密码错误'})

        else:
            return success(res={'error_code': 4002, 'msg': '手机号未注册'})
Ejemplo n.º 4
0
 def get(self):
     user_id = session.get("account_id")
     if not user_id:
         return success(res={})
     else:
         rn = AdminAccount.get(id=user_id)
         if rn:
             return success(res={'user': {'name': rn.tel}})
         else:
             return success(res={})
Ejemplo n.º 5
0
    def post(self):
        account = AdminAccount.get(id=session.get("account_id"))
        if not account:
            return success(res={"error_code": 4001, 'msg': '请登入'})

        post = request.form
        job_class = post.get("job_class")
        job_name = post.get("job_name")
        job_department = post.get('job_department')
        job_category = post.get("job_category")
        job_experience = post.get("job_experience")
        education = post.get("education")
        salary_start = post.get("salary_start")
        salary_end = post.get("salary_end")
        location = post.get("location")
        description = post.get("description")
        temptation = post.get("temptation")
        option = post.get("option")

        if (not job_class) or (not job_name) or (not job_department) or (
                not job_category) or (not job_experience) or (
                    not education) or (not description) or (not location) or (
                        not temptation):
            return success(res={"error_code": 4001, 'msg': '字段缺失'})

        data = {
            'name': job_name,
            'accounts': account,
            'department': job_department,
            'category': int(job_category),
            'experience': int(job_experience),
            'education': int(education),
            'salary_start': int(salary_start),
            'salary_end': int(salary_end),
            'location': location,
            'description': description,
            'classes': int(job_class),
            'temptation': temptation,
        }

        if option == 'update':
            job_id = post.get("job_id")
            rn = Job.update_doc(id=job_id, **data)
        else:
            rn = Job.create(**data)

        if rn:
            return success(res={'id': rn.id})
        else:
            return success(res={'error_code': 4001, 'msg': u'保存失败'})
Ejemplo n.º 6
0
    def post(self):
        post = request.form
        tel = post.get("tel")
        passwd = post.get("passwd")

        if len(passwd) < 6:
            return success(res={'error_code': 4001, 'msg': '密码不得小于6位'})

        rn = Account.objects(tel=tel).first()
        if not rn:
            return success(res={'error_code': 4001, 'msg': '用户不存在'})
        passwd = str(passwd)
        hash_passwd = hmac.new(passwd)
        hash_passwd.update(passwd[1:5])
        data = {'password': hash_passwd.hexdigest()}
        obj = Account.update_doc(id=rn.id, **data)
        return success(res={'user_id': obj.id, 'msg': '用户不存在'})
Ejemplo n.º 7
0
    def post(self):
        post = request.form
        tel = post.get("tel")
        recv_code = post.get("recv_code")

        if not tel:
            return success(res={'error_code': 4001, 'msg': '字段缺失'})

        rn = AdminAccount.objects(tel=tel).first()

        if rn:
            key = model.CHECKCODE_KEY.format(tel=tel)
            code = cache.get(key)
            if recv_code == str(code):
                session['account_id'] = rn.id
                return success()
            else:
                print recv_code, str(code)
                return success(res={'error_code': 4001, 'msg': '验证码错误'})

        else:
            return success(res={'error_code': 4002, 'msg': '手机号未注册'})
Ejemplo n.º 8
0
    def post(self):
        post = request.form
        job_id = post.get("job_id")
        option = post.get("option")

        if option == "update":
            box_id = post.get("box_id")
            drop_state = post.get("drop_state")
            data = {
                'drop_state': int(drop_state)
            }
            rn = Box.update_doc(id=box_id, **data)
        else:
            if not job_id:
                return success(res={"error_code": 4001, 'msg': '参数错误'})
            count = len(Box.objects(state=100, accounts=session.get("user_id")))
            if count > 2:
                return success(res={'error_code': 4001, 'msg': '已投递3份简历,到达上限!'})

            resume_rn = Resume.objects(state=100, accounts=session.get("user_id")).first()

            if not resume_rn:
                return success(res={'error_code': 4004, 'msg': '暂无简历,确认创建简历?'})

            data = {
                "jobs": Job.get(id=job_id),
                'drop_state': 100,
                "accounts": Account.get(id=session.get("user_id")),
                'resumes': resume_rn.id
            }

            rn = Box.create(**data)

        if not rn:
            return success(res={'error_code': 4001, 'msg': '投递失败'})

        return success(res={'id': rn.id})
Ejemplo n.º 9
0
    def post(self):
        post = request.form
        song_id = post.get("job_id")
        name = post.get("name")
        if not song_id and not name:
            return bad_request(message=u'参数缺失')

        if not name or not song_id:
            return bad_request(message=u'参数缺失')
        else:
            try:
                song_id = int(song_id)
            except ValueError:
                return bad_request(message=u'id错误')

        data = {'song_id': song_id, 'state': 100, 'name': name}

        rn = Song.create(**data)

        if not rn:
            return bad_request(message='4001')
        else:
            return success(res={'msg': 'ok'})
Ejemplo n.º 10
0
    def post(self):
        post = request.form
        tel = post.get("tel")
        name = post.get('name')
        code = post.get('code')
        passwd = post.get('passwd')

        if not code or not name or not passwd:
            return success(res={'error_code': 4001})

        if Account.objects(tel=tel):
            return success(res={'error_code': 4001, 'msg': '手机已注册'})

        if len(passwd) < 6:
            return success(res={'error_code': 4001})

        key = model.CHECKCODE_KEY.format(tel=tel)

        passwd = str(passwd)
        hash_passwd = hmac.new(passwd)
        hash_passwd.update(passwd[1:5])

        if code == cache.get(key):
            img_key = post.get('img_key')
            if not img_key:
                img_key = 'head.jpg'
            data = {'tel': tel, 'name': name, 'password': hash_passwd.hexdigest(), 'state': 100,
                    'head_img_key': img_key}
            rn = Account.create(**data)
        else:
            return success(res={'error_code': 4001, 'msg': '验证码错误'})

        if not rn:
            return success(res={'error_code': 4001})
        else:
            session['user_id'] = rn.id
            return success()
Ejemplo n.º 11
0
            pass

        try:
            os.mkdir('resume_file/{0}/{1}/{2}'.format(year, month, day))
        except OSError, e:
            pass

        img_f = os.path.join(
            'resume_file/{0}/{1}/{2}/'.format(year, month, day), img_time)
        with open(img_f, 'wb+') as f:
            f.write(data)
        # ResizeImage(filein=img_f, fileout=out_f, width=1193, height=570, i_type=imgType)
        qiniu_config = config.get("QINIU")
        a_key = qiniu_config.get('access_key')
        s_key = qiniu_config.get("secret_key")
        bucket_name = qiniu_config.get("bucket_name")

        q = Auth(access_key=a_key, secret_key=s_key)
        key = img_f
        token = q.upload_token(bucket_name, key)
        localfile = img_f
        name_url = qiniu_config.get("url")

        ret, info = put_file(token, key, localfile)
        if ret.get("key") == key:
            url = '{0}/{1}'.format(name_url, key)
            # url = get_photo(key=key, size='small')
            return success(res={'url': url, 'file_key': key})
        else:
            return success(res={'error_code': 4001})
Ejemplo n.º 12
0
    def get(self):
        args = request.args
        page = int(args.get("page"))
        limit = int(args.get("limit"))
        option = args.get("option")
        drop_state = int(args.get("drop_state"))

        job_list = []
        if option == 'all':
            # if not job_class and job_class == '0':
            data = {}
            if drop_state:
                data = {
                    'drop_state': drop_state,
                }

            box_rn = Box.objects(**data).all()
            obj = Job.pagination(page=page, limit=limit, rn=box_rn)
            for box in obj.get("data"):
                job = Job.get(id=box.jobs.id)
                resume = Resume.get(id=box.resumes.id)
                if not job:
                    continue

                create_time = box.created_at.strftime("%Y-%m-%d")
                job_list.append(
                    {
                        "drop_state": box.drop_state,
                        "name": job.name,
                        'time': create_time,
                        'department': job.department,
                        'classes': JOB_CLASS.get(job.classes),
                        'resume_name': resume.name,
                        'tel': resume.tel,
                        'resume_id': resume.id,
                        'drop_state': box.drop_state,
                        'box_id': box.id,
                        # 'location': job.location,
                        # 'salary': "{0}-{1}k".format(job.salary_start, job.salary_end),
                        # 'experience': EXPERIENCE.get(job.experience),
                        # 'education': LEVEL.get(job.education),
                        # 'temptation': job.temptation,
                        'id': job.id
                    }
                )
        else:
            data = {
                'state': 100,
                'accounts': session.get("user_id")
            }

            if drop_state:
                data['drop_state'] = int(drop_state)

            box_rn = Box.objects(**data).all()
            obj = Job.pagination(page=page, limit=limit, rn=box_rn)
            for box in obj.get("data"):
                job = Job.get(id=box.jobs.id)
                if not job:
                    continue

                create_time = job.created_at.strftime("%Y-%m-%d")
                job_list.append(
                    {
                        "drop_state": box.drop_state,
                        "name": job.name,
                        'time': create_time,
                        'department': job.department,
                        'classes': JOB_CLASS.get(job.classes),
                        'location': job.location,
                        'salary': "{0}-{1}k".format(job.salary_start, job.salary_end),
                        'experience': EXPERIENCE.get(job.experience),
                        'education': LEVEL.get(job.education),
                        'temptation': job.temptation,
                        'id': job.id
                    }
                )

        obj['data'] = job_list

        return success(res={'data': job_list})
Ejemplo n.º 13
0
    def post(self):
        account = Account.get(id=session.get("user_id"))
        if not account:
            return success(res={"error_code": 4001, 'msg': '请登入'})

        post = request.form
        name = post.get("name")
        tel = post.get("tel")
        sex = post.get('sex')
        email = post.get("email")
        birthday = post.get("birthday")

        if (not name) or (not tel) or (not sex) or (not email):
            return success(res={"error_code": 4001, 'msg': '字段缺失'})

        school = post.get("school", '')
        major = post.get("major", '')
        level = int(post.get("level", 2))
        graduation_date = post.get("graduation_date", '')

        company = post.get("company", '')
        job = post.get("job", '')
        job_date_start = post.get("job_date_start", '')
        job_date_end = post.get("job_date_end", '')
        job_content = post.get("job_content", '')

        expect_job = post.get("expect_job", '')
        expect_salary = post.get("expect_salary")
        if expect_salary:
            expect_salary = int(expect_salary)
        else:
            expect_salary = 0
        postscript = post.get("postscript", '')

        description = post.get("description", '')
        file_key = post.get("file_key", '')
        filename = post.get("filename", '')

        data = {
            'name':
            name,
            'tel':
            tel,
            'sex':
            sex,
            'accounts':
            account,
            'email':
            email,
            'birthday':
            birthday,
            'education': [{
                'school': school,
                'major': major,
                'level': level,
                'graduation_date': graduation_date
            }],
            'experience': [{
                'company': company,
                'job': job,
                'job_date_start': job_date_start,
                'job_date_end': job_date_end,
                'job_content': job_content
            }],
            'expect_job':
            expect_job,
            'expect_salary':
            expect_salary,
            'postscript':
            postscript,
            'description':
            description,
            'file_key':
            file_key,
            'file_name':
            filename,
        }

        obj = Resume.objects(accounts=account).first()
        if obj:
            rn = Resume.update_doc(obj.id, **data)
        else:
            rn = Resume.create(**data)
        if rn:
            return success(res={})
        else:
            return success(res={'error_code': 4001, 'msg': u'保存失败'})
Ejemplo n.º 14
0
    def get(self):
        args = request.args
        job_class = args.get("job_class")
        page = int(args.get("page"))
        limit = int(args.get("limit"))
        option = args.get("option")

        job_list = []
        if option == 'all':
            if not job_class or job_class == '0':
                rn = Job.objects().all()
            else:
                rn = Job.objects(classes=int(job_class)).all()
            obj = Job.pagination(page=page, limit=limit, rn=rn)
            for job in obj.get("data"):
                create_time = job.created_at.strftime("%Y-%m-%d %H:%M:%S")
                job_list.append({
                    "name": job.name,
                    'department': job.department,
                    'time': create_time,
                    'classes': JOB_CLASS.get(job.classes),
                    'location': job.location,
                    'id': job.id
                })
        else:
            experience = args.get("experience")
            category = args.get("category")
            data = {'state': 100}
            if job_class and job_class != '0':
                data['classes'] = int(job_class)

            if experience and experience != '0':
                data['experience'] = int(experience)

            if category and category != '0':
                data['category'] = int(category)

            rn = Job.objects(**data).all()
            obj = Job.pagination(page=page, limit=limit, rn=rn)
            for job in obj.get("data"):
                create_time = job.created_at.strftime("%Y-%m-%d")
                job_list.append({
                    "name":
                    job.name,
                    'time':
                    create_time,
                    'department':
                    job.department,
                    'classes':
                    JOB_CLASS.get(job.classes),
                    'location':
                    job.location,
                    'salary':
                    "{0}-{1}k".format(job.salary_start, job.salary_end),
                    'experience':
                    EXPERIENCE.get(job.experience),
                    'education':
                    LEVEL.get(job.education),
                    'temptation':
                    job.temptation,
                    'id':
                    job.id
                })

        obj['data'] = job_list

        return success(res={'data': job_list})
Ejemplo n.º 15
0
 def post(self):
     session.clear()
     return success()