示例#1
0
def new_pass():
    form = NewPassword(request.form)
    phone = get_argument("phone")
    email = get_argument("email")
    repeat = get_argument("repeat")
    if repeat:
        if email:
            UserProxy.verify(email=email)
        elif phone:
            UserProxy.verify(phone=phone)
        return render_template('input/new_pass.html', form=form)

    if form.validate_on_submit():
        try:
            code = form.code.data
            if email:
                user = UserProxy.signup_verify_code(email=email, code=code)
            elif phone:
                user = UserProxy.signup_verify_code(phone=phone, code=code)

            session["user_obj"] = user.set_default()
            login_user(user, remember=True)

            user.set_properties({password:form.password.data})

            if not user.is_active():
                return redirect(url_for('signup'))

            return redirect(url_for('welcome'))
        except HTTPError, e:
            make_error_response(e)
示例#2
0
def change_username():
    password = get_argument("password")
    username = get_argument("username")
    try:
        g.user.set_properties_with_password( pwd = password, username = username )
        return json.dumps({"success": True})
    except HTTPError, e:
        return json.dumps({"success": False, "msg": unicode(SERVER_ERRORS.get(e.code, e.msg))})
示例#3
0
def change_phone_confirm():
    verifyPhone = get_argument("verifyPhone")
    code = get_argument("code")
    try:
        g.user.confirm_mail_or_phone( phone = verifyPhone, code = code )
        return json.dumps({"success": True})
    except HTTPError, e:
        return json.dumps({"success": False, "msg": unicode(SERVER_ERRORS.get(e.code, e.msg))})
示例#4
0
def change_fullname():
    password = get_argument("password")
    fullname = get_argument("fullname")
    print "len(fullname): ", len(fullname)
    try:
        g.user.set_properties_with_password(pwd=password, fullname=fullname)
        return json.dumps({"success": True})
    except HTTPError, e:
        make_error_response(e)
示例#5
0
def change_password():
    password = get_argument("password")
    newpassword = get_argument("newpassword")
    confirm = get_argument("confirm")
    if confirm != newpassword:
        return json.dumps({"success": False, "msg":unicode( _("Passwords must match"))})
    try:
        g.user.set_properties_with_password( pwd = password, password = newpassword )
        return json.dumps({"success": True})
    except HTTPError, e:
        return json.dumps({"success": False, "msg": unicode(SERVER_ERRORS.get(e.code, e.msg))})
示例#6
0
def change_verify():
    email = get_argument("email")
    phone = get_argument("phone")
    try:
        if email:
            UserProxy.verify( email = email )
        elif phone:
            UserProxy.verify( phone = phone )
        else:
            return json.dumps({"success": False, "msg": unicode(_("Need 'email' or 'phone' in arguments"))})
    except HTTPError, e:
        return json.dumps({"success": False, "msg": unicode(SERVER_ERRORS.get(e.code, e.msg))})
示例#7
0
def article_blocks_move(art_id, branch_id, commit_id):
    article = Article( { "uuid": art_id, "selected_branch" : {'uuid': branch_id}, "selected_commit" : {'uuid': commit_id }} )
    block_uuids = get_argument('block_uuids')
    prev_block_uuid = get_argument('prev_block_uuid')
    try:
        params = {
            "block_uuids": block_uuids,
            "prev_block_uuid": prev_block_uuid
        }
        res = article.move_blocks(**params)
        return jsonify(res)
    except HTTPError, e:
        return make_error_response(e)
示例#8
0
def leaf_pull(dest_leaf_id):
    src_block_commit_uuid_pairs = get_argument('src_block_commit_uuid_pairs')
    dest_prev_block_uuid = get_argument('dest_prev_block_uuid')
    try:
        params = {
            "src_block_commit_uuid_pairs": src_block_commit_uuid_pairs,
            "dest_leaf_id": dest_leaf_id,
            "dest_prev_block_uuid": dest_prev_block_uuid
        }
        res = ArticleProxy.pull_blocks(**params)
        return jsonify(res)
    except HTTPError, e:
        return make_error_response(e)
示例#9
0
def article(art_id):
    try:
        result = {}
        article = Article( { "uuid": art_id } )
        if request.method == 'DELETE':
            result = article.delete( )
        elif request.method == 'PATCH':
            title = get_argument('title')
            description = get_argument('description')
            result = article.update( title=title, description=description )
        return jsonify(result)
    except HTTPError, e:
        return make_error_response(e)
示例#10
0
def change_tagline():
    tagline = get_argument("tagline")
    try:
        g.user.set_properties( {tagline:tagline} )
        return json.dumps({"success": True})
    except HTTPError, e:
        return json.dumps({"success": False, "msg": unicode(SERVER_ERRORS.get(e.code, e.msg))})
示例#11
0
def change_email():
    email = get_argument("email")
    try:
        g.user.request_change_properties( email = email )
        return json.dumps({"success": True})
    except HTTPError, e:
        return json.dumps({"success": False, "msg": unicode(SERVER_ERRORS.get(e.code, e.msg))})
示例#12
0
def change_phone():
    phone = get_argument("phone")
    try:
        g.user.request_change_properties( phone = phone )
        return json.dumps({"success": True})
    except HTTPError, e:
        return json.dumps({"success": False, "msg": unicode(SERVER_ERRORS.get(e.code, e.msg))})
示例#13
0
def article_invite_members(art_id):
    try:
        article = Article({'uuid': art_id})
        members = get_argument('members', [])
        article.invite_members(members)
        return make_response()
    except HTTPError, e:
        return make_error_response(e)
示例#14
0
def article_blocks_delete( art_id, branch_id, commit_id):
    # print     art_id, block_id
    article = Article( {"uuid": art_id, "selected_branch" : {'uuid': branch_id}, "selected_commit" : {'uuid': commit_id }} )
    block_uuids = get_argument('block_uuids')
    try:
        result = article.delete_blocks(block_uuids)
        return jsonify(result)
    except HTTPError, e:
        return make_error_response(e)
示例#15
0
def leaf_diffs(leaf_id):
    try:
        src_commit_id = get_argument('src_commit_uuid', None)
        article = ArticleProxy.get_diffs(leaf_id, src_commit_id)
        result = {}
        result['article'] = article.json()
        return jsonify(result)
    except HTTPError, e:
        return make_error_response(e)
示例#16
0
def article_commits( art_id):
    try:
        branch_id = get_argument("branch")
        article = Article( {"uuid": art_id, "selected_branch" : {'uuid': branch_id }} )
        if request.method == 'GET':
            res = article.get_commits()
            result = {}
            result['article'] = article.json()
            result['article']['commits'] = res['commits']
            result['article']['commits_count'] = res['count']
            result['article']['commits_offset'] = res['offset']
            result['article']['commits_limit'] = res['limit']
            return jsonify(result)
        elif request.method == 'POST':
            src_commit_id = get_argument("src_commit")
            title = get_argument("title")
            description = get_argument("description")
            result = article.create_commit(src_commit_id, title, description)
            result["success"] = True
            return jsonify(result)
    except HTTPError, e:
        return make_error_response(e)
示例#17
0
def article_block_update( art_id, branch_id, commit_id, block_id ):
    article = Article( { "uuid": art_id, "selected_branch" : {'uuid': branch_id}, "selected_commit" : {'uuid': commit_id }} )
    try:
        type = get_argument("type")
        subtype = get_argument("subtype")
        content = get_argument("content")
        title = get_argument("title")
        caption = get_argument("caption")
        metadata = get_argument("metadata")
        status = get_argument("status")
        weight = get_argument("weight")
        result = article.update_block(block_id, type=type, subtype=subtype, title=title, content=content, caption=caption, metadata=metadata, status=status, weight=weight)
        return jsonify(result)
    except HTTPError, e:
        return make_error_response(e)