Пример #1
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="修改失败")
Пример #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="修改失败")
Пример #3
0
def add_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="属性值不能为空")
        if Item.find_attr(title, attr_name) is not None:
            return jsonify(status=False, reason="属性已存在")
        status = Item.add_attr(title, attr_name, attr_value, attr_type)
        if status:
            if current_user.is_authenticated:
                current_user.add_edit()
        html = TypeRender.render_html(attr_name, attr_value, attr_type)
        return jsonify(status=True, reason="添加属性成功", html=html)
Пример #4
0
def add_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="属性值不能为空")
        if Item.find_attr(title, attr_name) is not None:
            return jsonify(status=False, reason="属性已存在")
        status = Item.add_attr(title, attr_name, attr_value, attr_type)
        if status:
            if current_user.is_authenticated:
                current_user.add_edit()
        html = TypeRender.render_html(attr_name, attr_value, attr_type)
        return jsonify(status=True, reason="添加属性成功", html=html)
Пример #5
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")
Пример #6
0
def add_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")
        if Item.find_attr(title, attr_name) is not None:
            return jsonify(status=False, reason="Attributes have been existed")
        status = Item.add_attr(title, attr_name, attr_value, attr_type)
        if status:
            if current_user.is_authenticated:
                current_user.add_edit()
        html = TypeRender.render_html(attr_name, attr_value, attr_type)
        return jsonify(status=True,
                       reason="Add attributes successfully",
                       html=html)