Esempio n. 1
0
def add_myself(user_id, mate_gender):
    p = Plan.add(user_id)
    my_gender = u'男性' if mate_gender == u'女性' else u'女性'
    p.data.update(owner=u'自己',
                  marrige=u'已婚',
                  gender=my_gender,
                  href=url_for('ins.plan.consulting', plan_id=p.id),
                  is_completed=False,
                  accident_coverage='',
                  id=p.id)
Esempio n. 2
0
def add_login_plan(user_id, request_dict):
    plan = Plan.add(user_id)
    plan.data.update(href=url_for('ins.plan.consulting', plan_id=plan.id),
                     is_completed=False)
    plan.update_plan(request_dict, url_for('ins.plan.planning',
                                           plan_id=plan.id))
    session['plan_id'] = plan.id
    if len(Plan.get_user_plan_dict(g.user.id)) == 1 and \
            plan.data.owner.decode('utf-8') == u'配偶':
        add_myself(g.user.id, plan.data.gender.decode('utf-8'))
    return plan
Esempio n. 3
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)[0]

        self.assertTrue(plan)
        self.assertEqual(plan.id, pid)
Esempio n. 4
0
def update_session_to_plan(user_id, session_str):
    if Plan.get_user_plan_dict(user_id):
        session.pop('ins_plan', None)
        # session.pop('uuid', None)
        return
    session_dict = json.loads(session_str)
    plan = Plan.add(user_id)
    plan.data.update(is_completed=False,
                     href=url_for('ins.plan.consulting', plan_id=plan.id))
    plan.update_plan(session_dict, url_for('ins.plan.planning',
                                           plan_id=plan.id))
    session.pop('ins_plan', None)
    # session.pop('uuid', None)
    if session_dict.get('owner') and session_dict.get('owner') == u'配偶':
        add_myself(user_id, session_dict.get('gender'))
Esempio n. 5
0
def add_mate_plan(user_id, owner):
    plan_dict = Plan.get_user_plan_dict(user_id)
    plan = Plan.add(g.user.id)
    plan.data.update(
        is_completed=False,
        href=url_for('ins.plan.consulting', plan_id=plan.id),
        id=plan.id,
        marriage=u'已婚',
        gender=u'男性' if plan_dict[0]['gender'] == u'女性' else u'女性',
        owner=owner,
    )
    return jsonify(is_login=True,
                   id=plan.id,
                   href=plan.data.href,
                   is_completed=plan.data.is_completed,
                   gender=plan.data.gender), 200
Esempio n. 6
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)
Esempio 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)