示例#1
0
def store_add_post():
    """
    store 添加商店

    """
    db = g._imdb
    developer_id = session['user']['id']

    appid = config.KEFU_APPID
    name = request.form['name'] if request.form.has_key('name') else None
    if not name:
        return INVALID_PARAM()

    db.begin()
    gid = Group.create_group(db, appid, 0, name, False)
    store_id = Store.create_store(db, name, gid, developer_id)
    db.commit()

    #将名称存储redis,用于后台推送
    Store.set_store_name(g.im_rds, store_id, name)

    content = "%d,%d,%d" % (gid, appid, 0)
    publish_message(g.im_rds, "group_create", content)

    obj = {"store_id": store_id}

    return redirect(url_for('.store_index'))
示例#2
0
def store_add_post():
    """
    store 添加商店

    """
    db = g._imdb
    developer_id = session['user']['id']
    
    appid = config.KEFU_APPID
    name = request.form['name'] if request.form.has_key('name') else None
    if not name:
        return INVALID_PARAM()

    mode = default_mode
    db.begin()
    if mode == MODE_BROADCAST:
        gid = Group.create_group(db, appid, 0, name, False)
    else:
        gid = 0
    store_id = Store.create_store(db, name, gid, mode, developer_id)
    db.commit()

    #将名称存储redis,用于后台推送
    Store.set_store_name(g.im_rds, store_id, name)

    if gid:
        content = "%d,%d,%d"%(gid, appid, 0)
        publish_message(g.im_rds, "group_create", content)

    obj = {"store_id":store_id}

    return redirect(url_for('.store_index'))
示例#3
0
文件: api.py 项目: jzxyouok/kefu_web
def add_store():
    db = g._imdb
    developer_id = g.developer_id
    appid = KEFU_APPID
    name = request.form['name'] if request.form.has_key('name') else None
    if not name:
        return INVALID_PARAM()

    mode = default_mode
    db.begin()
    if mode == MODE_BROADCAST:
        gid = Group.create_group(db, appid, 0, name, False)
    else:
        gid = 0
    store_id = Store.create_store(db, name, gid, mode, developer_id)
    db.commit()

    #将名称存储redis,用于后台推送
    Store.set_store_name(g.im_rds, store_id, name)

    if gid:
        content = "%d,%d,%d"%(gid, appid, 0)
        publish_message(g.im_rds, "group_create", content)

    obj = {"store_id":store_id}
    return make_response(200, obj)
示例#4
0
def verify_mail():
    """
    """
    email = request.form.get('email', '')
    password = request.form.get('password', '')
    password = generate_password_hash(password)

    account_obj = _get_account_by_email(g._db, email)
    if account_obj:
        raise MainException.ACCOUNT_DUPLICATE

    code = random_ascii_string(40)

    appid = config.KEFU_APPID
    db = g._db

    mode = 1  #fix_mode
    db.begin()
    store_id = Store.create_store(db, '', 0, mode, 0)
    account_id = Seller.add_seller(db, email, password, store_id, email, 0)
    Account.insert_verify_email(db, email, code, EmailUsageType.SELLER_VERIFY,
                                account_id)
    db.commit()

    Store.add_seller_id(g.im_rds, store_id, account_id)

    if 'user' not in session:
        session['user'] = {}

    session['user']['id'] = account_id
    session['user']['email'] = email
    session['user']['email_checked'] = 0
    session['user']['store_id'] = store_id
    session['user']['name'] = email

    account = {
        "id": account_id,
        "email": email,
        "email_checked": 0,
    }

    send_verify_email(email,
                      code,
                      email_cb=url_for('account.register_valid',
                                       code='',
                                       _external=True))

    return send_response(account)