Example #1
0
File: views.py Project: ThinkZ/pkyx
def edit_attr():
    if request.method == 'POST':
        title = request.json['title']
        attr_name = request.json['attr_name'].strip()
        attr_type = request.json['attr_type']
        attr_value = request.json['attr_value'].strip()
        if not attr_name:
            return jsonify(status=False, reason="属性名不能为空")
        if not attr_value:
            return jsonify(status=False, reason="属性值不能为空")
        status = Item.edit_attr(title, attr_name, attr_value, attr_type)
        if status:
            if current_user.is_authenticated:
                current_user.add_edit()
            return jsonify(status=True, reason="修改属性成功")
        else:
            return jsonify(status=True, reason="修改失败")
Example #2
0
def edit_attr():
    if request.method == 'POST':
        title = request.json['title']
        attr_name = request.json['attr_name'].strip()
        attr_type = request.json['attr_type']
        attr_value = request.json['attr_value'].strip()
        if not attr_name:
            return jsonify(status=False, reason="属性名不能为空")
        if not attr_value:
            return jsonify(status=False, reason="属性值不能为空")
        status = Item.edit_attr(title, attr_name, attr_value, attr_type)
        if status:
            if current_user.is_authenticated:
                current_user.add_edit()
            return jsonify(status=True, reason="修改属性成功")
        else:
            return jsonify(status=True, reason="修改失败")
Example #3
0
def edit_attr():
    if request.method == 'POST':
        title = request.json['title']
        attr_name = request.json['attr_name'].strip()
        attr_type = request.json['attr_type']
        attr_value = request.json['attr_value'].strip()
        if not attr_name:
            return jsonify(status=False,
                           reason="Property name cannot be empty")
        if not attr_value:
            return jsonify(status=False,
                           reason="Property name cannot be empty")
        status = Item.edit_attr(title, attr_name, attr_value, attr_type)
        if status:
            if current_user.is_authenticated:
                current_user.add_edit()
            return jsonify(status=True, reason="Edit succeed")
        else:
            return jsonify(status=True, reason="Edit fail")