コード例 #1
0
ファイル: add_channel.py プロジェクト: c1xfr2e/soledad
def main():
    channels = [
        Account.channel_class.add(u'西方记者', 'west'),
        Account.channel_class.add(u'香港记者', 'hk'),
    ]
    for channel in channels:
        bcolors.run(repr(channel), key='channel')
コード例 #2
0
def main():
    user = Account.get_by_alias(EMAIL)
    if not user:
        user = register_without_confirm(EMAIL, 'testtest',
                                        ACCOUNT_REG_TYPE.EMAIL)
        bcolors.run(repr(user), key='zhiwang')

    # 绑定身份证和手机
    user.add_alias(MOBILE_PHONE, ACCOUNT_REG_TYPE.MOBILE)
    identity = Identity.save(user.id_, PERSON_NAME, PERSON_RICN)
    bcolors.run(repr(identity), key='zhiwang')

    # 绑定指旺帐号
    ZhiwangAccount.bind(user.id_, ZHIWANG_TOKEN)
    bcolors.run(repr(ZhiwangAccount.get_by_local(user.id_)), key='zhiwang')

    # 绑定银行卡
    bankcards = BankCardManager(user.id_)
    with patch('core.models.profile.bankcard.DEBUG', True):
        bankcard = bankcards.create_or_update(
            mobile_phone=user.mobile,
            card_number=BANKCARD_NO,
            bank_id=BANKCARD_BANK,
            city_id=BANKCARD_DIVISION[:4] + u'00',
            province_id=BANKCARD_DIVISION[:2] + u'0000',
            local_bank_name=u'')
        bcolors.run(repr(bankcard), key='zhiwang')
    bcolors.run('success: %s' % EMAIL, key='zhiwang')
コード例 #3
0
def main():
    user = Account.get_by_alias(EMAIL)
    ZhiwangAccount.unbind(user.id_)

    try:
        register_zhiwang_account(user.id_)
        zhiwang_account = ZhiwangAccount.get_by_local(user.id_)
    except (MismatchUserError, RepeatlyRegisterError) as e:
        bcolors.fail(e.args[0], key='zhiwang_code')
        return

    bcolors.run('The new zhiwang code is %s' % zhiwang_account.zhiwang_id,
                key='zhiwang_code')

    with open(ADD_ZHIWANG_FILE, 'r') as f:
        source = RE_ZHIWANG_CODE.sub(
            "ZHIWANG_TOKEN = u'%s'" %
            zhiwang_account.zhiwang_id.encode('ascii'), f.read())
    with open(ADD_ZHIWANG_FILE, 'w') as f:
        f.write(source)

    bcolors.run('%s is changed. PLEASE COMMIT IT AND OPEN A MERGE REQUEST.' %
                ADD_ZHIWANG_FILE,
                key='zhiwang_code')

    if '--commit' in sys.argv:
        subprocess.check_call(
            ['git', 'commit', '-m', COMMIT_MSG, '--', ADD_ZHIWANG_FILE])
コード例 #4
0
def generate_fake_annual_rates():
    for days in reversed(range(10)):
        date = datetime.date.today() - datetime.timedelta(days=days)
        annual_rate = decimal.Decimal(abs(math.sin(decimal.Decimal(days)))) * 3
        annual_rate = annual_rate + decimal.Decimal('1.1')
        ttp_income = decimal.Decimal('1.0')
        rate = WalletAnnualRate.record(
            date, annual_rate, ttp_income, provider.fund_code)
        bcolors.run(repr(rate), key='wallet')
コード例 #5
0
ファイル: mq.py プロジェクト: c1xfr2e/soledad
 def loop(self):
     app = create_app()
     with app.app_context():
         bcolors.run('Worker start at mq tube [%s]...' % self.tube)
         try:
             while True:
                 self.consume()
         except KeyboardInterrupt:
             bcolors.success('Worker at mq tube [%s] success stopped.' %
                             self.tube)
コード例 #6
0
ファイル: add_placebo.py プロジェクト: c1xfr2e/soledad
def main():
    product = PlaceboProduct.add(strategy=strategies.strategy_2016_spring,
                                 min_amount=decimal.Decimal(8888),
                                 max_amount=decimal.Decimal(8888),
                                 start_sell_date=datetime.date.today(),
                                 end_sell_date=datetime.date.today() +
                                 datetime.timedelta(days=3),
                                 frozen_days=7,
                                 annual_rate=decimal.Decimal('6.6'))
    bcolors.run('success: %s' % product, key='placebo')
コード例 #7
0
def main():
    user = Account.get_by_alias(EMAIL)
    if not user:
        bcolors.fail('%s is not found' % EMAIL, key='firewood')

    flow = FirewoodWorkflow(user.id_)

    transaction = firewood.create_transaction(flow.account_uid, AMOUNT, TAGS)
    transaction_uid = uuid.UUID(transaction.json()['uid'])
    transaction = firewood.confirm_transaction(flow.account_uid,
                                               transaction_uid)
    transaction_uri = transaction.json()['_links']['self']

    bcolors.run('%s +100.00' % transaction_uri, key='firewood')
コード例 #8
0
def add_announcement():
    start_time = datetime.datetime.now() - datetime.timedelta(days=1)
    stop_time = datetime.datetime.now() + datetime.timedelta(days=1)

    announcement = Announcement.add(
        subject=u'开发和测试环境',
        subject_type=Announcement.SubjectType.notice,
        content=u'您现在在**开发和测试环境**中, 任何修改都不会影响生产环境',
        content_type=Announcement.ContentType.markdown,
        start_time=start_time,
        stop_time=stop_time,
        endpoint='*')

    bcolors.run(repr(announcement), key='site.announcement')
コード例 #9
0
def add_download():
    project = Project.add('guihua-android', u'好规划 Android App')

    r1 = project.add_release('0001', '0.1.0',
                             'b3799c5ff83840a350ca4376eccebb1965c418b1.apk')
    r2 = project.add_release('0002', '0.2.0',
                             '15b7aea3695dbde7334eb6ac264edfd76976fef6.apk')
    r3 = project.add_release('0003', '0.2.1',
                             '109625e5a6414aea08a72519d5eb0848311d7ae4.apk')

    r1.transfer_status(Release.Status.absent)
    r2.transfer_status(Release.Status.inhouse)
    r3.transfer_status(Release.Status.public)

    template = u'{0.project.display_name}\t{0.display_version}\t{0.status.name}'
    for r in project.list_releases():
        bcolors.run(template.format(r).encode('utf-8'), key='site.download')
コード例 #10
0
def main():
    bcolors.run('Add redeem code.')
    effective_time = datetime.now() - timedelta(days=1)
    expire_time = datetime.now() + timedelta(days=30)
    try:
        # 创建100个可被使用一次的兑换码
        RedeemCode.create_multi_codes(fanmeeting_gold.id_,
                                      RedeemCode.Kind.normal_package.value,
                                      u'测试用兑换码', 1, 100, effective_time,
                                      expire_time)
        # 创建一个可使用100次的兑换码
        RedeemCode.create(fanmeeting_silver.id_,
                          RedeemCode.Kind.normal_package.value, u'测试用兑换码', 100,
                          None, effective_time, expire_time)
        bcolors.success('Init redeemcode done.')
    except Exception as e:
        bcolors.fail('Init redeemcode fail: %s.' % e)
コード例 #11
0
def generate_fake_transactions():
    user = Account.get_by_alias('*****@*****.**')
    if not user:
        return
    with patch('core.models.profile.bankcard.DEBUG', True):
        b1 = BankCard.add(
            user_id=user.id_,
            mobile_phone='13800138000',
            card_number='6222000000000009',
            bank_id='4',  # 建设银行
            city_id='110100',  # 朝阳
            province_id='110000',  # 北京
            local_bank_name='西夏支行',
            is_default=True)
        b2 = BankCard.add(
            user_id=user.id_,
            mobile_phone='13800138000',
            card_number='6222000000010008',
            bank_id='10002',  # 中信银行
            city_id='110100',  # 朝阳
            province_id='110000',  # 北京
            local_bank_name='天龙寺支行',
            is_default=True)

    bcolors.run(repr(b1), key='wallet')
    bcolors.run(repr(b2), key='wallet')

    wallet_account = WalletAccount.get_or_add(user, zhongshan)
    t1 = WalletTransaction.add(
        wallet_account, b1, decimal.Decimal('40'),
        WalletTransaction.Type.purchase, uuid.uuid4().hex, WalletTransaction.Status.failure)
    t2 = WalletTransaction.add(
        wallet_account, b1, decimal.Decimal('42'),
        WalletTransaction.Type.purchase, uuid.uuid4().hex, WalletTransaction.Status.success)
    t3 = WalletTransaction.add(
        wallet_account, b2, decimal.Decimal('10'),
        WalletTransaction.Type.redeeming, uuid.uuid4().hex, WalletTransaction.Status.success)

    bcolors.run(repr(t1), key='wallet')
    bcolors.run(repr(t2), key='wallet')
    bcolors.run(repr(t3), key='wallet')
コード例 #12
0
ファイル: add_oauth.py プロジェクト: c1xfr2e/soledad
def main():
    bcolors.run('Add OAuth client.')
    client = OAuthClient.add(name=u'OAuthy',
                             redirect_uri=get_redirect_uri(),
                             allowed_grant_types=[
                                 'authorization_code', 'password',
                                 'refresh_token'
                             ],
                             allowed_response_types=['token', 'code'],
                             allowed_scopes=[
                                 OAuthScope.user_info, OAuthScope.savings_r,
                                 OAuthScope.savings_w, OAuthScope.wallet_r,
                                 OAuthScope.wallet_w
                             ])
    client_args = (client.name, client.client_id, client.client_secret)
    bcolors.run('%s: %s %s ' % client_args, key='oauth')

    bcolors.run('Add OAuth authorization.')
    app = create_app()
    with app.app_context(), app.test_client() as http:
        r = http.post(
            url_for('api.oauth.access_token'),
            data={
                'grant_type': 'password',
                'client_id': client.client_id,
                'client_secret': client.client_secret,
                'username': '******',
                'password': '******',
                'scope':
                'basic user_info savings_r savings_w wallet_r wallet_w',
            })

        if not bearychat.configured:
            return
        bearychat.say(TEMPLATE.format(client.client_id, client.client_secret))

    data = json.loads(r.data)
    bcolors.run(' '.join('%s=%s' % pair for pair in data.items()), key='oauth')
コード例 #13
0
ファイル: add_location.py プロジェクト: c1xfr2e/soledad
    (652200, '哈密地区', 650000),
    (652300, '昌吉回族自治州', 650000),
    (652700, '博尔塔拉蒙古自治州', 650000),
    (652800, '巴音郭楞蒙古自治州', 650000),
    (652900, '阿克苏地区', 650000),
    (653000, '克孜勒苏柯尔克孜自治州', 650000),
    (653100, '喀什地区', 650000),
    (653200, '和田地区', 650000),
    (654000, '伊犁哈萨克自治州', 650000),
    (654200, '塔城地区', 650000),
    (654300, '阿勒泰地区', 650000),
    (710000, '台湾省', 100000),
    (710100, '台湾地区', 710000),
    (810000, '香港特别行政区', 100000),
    (810100, '香港地区', 810000),
    (820000, '澳门特别行政区', 100000),
    (820100, '澳门地区', 820000),
]

bcolors.run('Add Location.')
try:
    for r in CITIES:
        db.execute(
            'insert into location '
            '(id, name_cn, parent_id) '
            'values (%s, %s, %s)', r)
    db.commit()
    bcolors.success('Add Location Done.')
except Exception as e:
    bcolors.fail('Init data fail: %r' % e)
コード例 #14
0
# coding: utf-8

"""
创建测试用礼券
"""

from libs.utils.log import bcolors
from core.models.user.account import Account
from core.models.welfare.package.kind import test_newcomer_center


if __name__ == '__main__':
    bcolors.run('Add coupons.')

    # in init_user we create test%[email protected]
    try:
        emails = ['*****@*****.**' % r for r in range(9)]
        emails.append('*****@*****.**')
        for email in emails:
            user = Account.get_by_alias(email)
            package = test_newcomer_center.distributor.bestow(user)
            package.unpack(user)
        bcolors.success('Init coupon done.')
    except Exception as e:
        bcolors.fail('Init coupon fail: %s.' % e)
コード例 #15
0
ファイル: add_insurance.py プロジェクト: c1xfr2e/soledad
    status = '1'
    rank_in_pkg = '2'
    rec_rank = '1'
    Package.add(pkg_id, pkg_map[pkg_id], ins_id, ins_map[ins_id], status,
                rank_in_pkg, rec_rank)

    pkg_id = '6'
    ins_id = '2'
    status = '1'
    rank_in_pkg = '1'
    rec_rank = '1'
    Package.add(pkg_id, pkg_map[pkg_id], ins_id, ins_map[ins_id], status,
                rank_in_pkg, rec_rank)


if __name__ == '__main__':
    bcolors.run('add_insurance insurance.')
    add_insurance(0, 1, u'ins1', 1, 1)
    add_insurance(0, 2, u'ins2', 1, 1)
    add_insurance(0, 3, u'ins3', 1, 1)
    add_insurance(0, 4, u'ins4', 1, 1)
    add_insurance(0, 5, u'ins5', 1, 1)
    add_insurance(0, 6, u'ins6', 1, 1)
    add_insurance(0, 7, u'ins7', 1, 1)
    add_insurance(1, 8, u'ins8', 1, 1)
    add_insurance(1, 9, u'ins9', 1, 1)
    add_insurance(2, 10, u'ins10', 1, 1)

    add_package()
    add_insurance_props()
コード例 #16
0
ファイル: add_insurance.py プロジェクト: c1xfr2e/soledad
def add_insurance(kind, insurance_id, name, status, rec_rank):
    Insurance.add(kind, insurance_id, name, status, rec_rank)
    bcolors.run(u'insurance_id=%s,kind=%s,name=%s' %
                (insurance_id, kind, name),
                key='insurance')
コード例 #17
0
ファイル: add_user.py プロジェクト: c1xfr2e/soledad
    '3',
    'target': [{
        'money': '10000',
        'target': '2',
        'year': '5'
    }]
}


def add_user(name, alias, reg_type):
    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')
コード例 #18
0
# coding: utf-8

from libs.utils.log import bcolors
from core.models.hoarder.vendor import Vendor, Provider

if __name__ == '__main__':
    bcolors.run('Add product_vendor.')
    Vendor.add(Provider.sxb.value, 'sxb')
    Vendor.add(Provider.xm.value, 'xm')
    Vendor.add(Provider.zw.value, 'zw')
    Vendor.add(Provider.ms.value, 'ms')
    bcolors.success('Init product vendor done.')