Exemplo n.º 1
0
 def test_plan_steps(self):
     a = self.add_account()
     plan = Plan.add(a.id)
     pid = plan.id
     self.assertEqual(plan.step, 1)
     plan.update_step(2)
     plan = Plan.get(pid)
     self.assertEqual(plan.step, 2)
Exemplo n.º 2
0
    def test_get_plan_by_user(self):
        a = self.add_account()
        plan = Plan.add(a.id)
        self.assertTrue(plan)
        self.assertEqual(plan.user_id, a.id)

        pid = plan.id
        plan = Plan.get_by_user_id(a.id)

        self.assertTrue(plan)
        self.assertEqual(plan.id, pid)
Exemplo n.º 3
0
def _before_request():
    # redirects anonymous users to the login page
    if not g.user:
        return redirect(url_for('accounts.login.login', next=request.path))

    plan = Plan.get_by_user_id(g.user.id)
    g.plan = plan if plan else None
    if request.path.startswith('/mine/plan'):
        # TODO move to mine.plan
        if not g.plan:
            return redirect('/mine/info')
        report = Report.get_latest_by_plan_id(g.plan.id)
        if not report:
            return redirect('/mine/info')

        # stop gen pdf
        if not (report.status >= REPORT_STATUS.interdata):
            return redirect('/mine/info')

        if int(report.formula_ver) < int(FORMULA_VER):
            regen_log(report, 'start regenerate inter data')
            cal_intermediate_data(report, force=True, log=regen_log)
            report.update_formula_ver(FORMULA_VER)
            regen_log(
                report,
                'success regenerate inter data FV:%s' % report.formula_ver)

        g.report = report
        g.report_data = report.inter_data
Exemplo n.º 4
0
Arquivo: j.py Projeto: c1xfr2e/soledad
def get_plan_status():
    if not g.user:
        return jsonify(r=False)
    plan = Plan.get_by_user_id(g.user.id)
    if not plan:
        return jsonify(r=False)
    report = Report.get_latest_by_plan_id(plan.id)
    if not report:
        return jsonify(r=False)
    # stop gen pdf
    if report.status >= REPORT_STATUS.interdata:
        return jsonify(r=True)
    return jsonify(r=False)
Exemplo n.º 5
0
 def test_plan_secret_data_with_big_data(self):
     a = self.add_account()
     plan = Plan.add(a.id)
     plan.data.update(key='value',
                      haha='this is a very long text',
                      content='100' * 1000,
                      int_data=100,
                      some_key='some_key',
                      some_chinese_key='你好',
                      some_photo='asd' * 1024)
     plan.data.update(some_dict=dict(key='value'), some_list=[1, 2])
     self.assertFalse(plan.data.invalid)
     self.assertEqual(plan.data.key, 'value')
     self.assertEqual(plan.data.some_chinese_key, '你好')
     self.assertEqual(plan.data.some_photo, 'asd' * 1024)
     self.assertEqual(plan.data.some_dict.get('key'), 'value')
     self.assertTrue(1 in plan.data.some_list)
     self.assertTrue(2 in plan.data.some_list)
Exemplo n.º 6
0
def export_by_user(user_id):
    plan = Plan.get_by_user_id(user_id)
    report = Report.get_latest_by_plan_id(plan.id)

    if not plan or not report:
        return

    career = plan.data.get('career')
    city = gb2260.search(plan.data.get('city'))
    has_spouse = bool(int(plan.data.get('spouse') or '0'))
    has_children = bool(plan.data.get('children') or [])
    monthly_salary = plan.data.get('income_month_salary')
    rtc_rank_ratio = report.inter_data['rtc_rank_ratio']

    if city is None:
        logger.warning('ignore invalid city: %s' % plan.data.get('city'))
        return

    return {
        'career': career, 'province': city.province.name,
        'prefecture': city.prefecture.name, 'has_spouse': has_spouse,
        'has_children': has_children, 'monthly_salary': monthly_salary,
        'rtc_rank_ratio': rtc_rank_ratio, 'user_id': user_id}
Exemplo n.º 7
0
 def test_add_plan(self):
     a = self.add_account()
     plan = Plan.add(a.id)
     self.assertTrue(plan)
     self.assertEqual(plan.user_id, a.id)
Exemplo n.º 8
0
    passwd = 'testtest'
    return register_without_confirm(alias, passwd, reg_type)


if __name__ == '__main__':
    bcolors.run('Add users.')
    try:
        # add special account
        add_user('zw', '*****@*****.**', reg_type=ACCOUNT_REG_TYPE.EMAIL)

        for i in range(10):
            name = 'test%s' % i
            email = '*****@*****.**' % name
            u = add_user(name, email, reg_type=ACCOUNT_REG_TYPE.EMAIL)
            if i < 5:
                p = Plan.add(u.id)
                p.data.secret_db.set(p.data.props_name, d)
                p.update_step(6)
                bcolors.run('email=%s, password=%s, plan=%s' %
                            (email, 'testtest', p.id),
                            key='user')
            else:
                bcolors.run('email=%s, password=%s' % (email, 'testtest'),
                            key='user')

        for i in range(10):
            name = 'mobiletest%s' % i
            mobile = '159%s' % (repr(i) * 8)
            u = add_user(name, mobile, reg_type=ACCOUNT_REG_TYPE.MOBILE)
            if i < 5:
                p = Plan.add(u.id)