Exemplo n.º 1
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)
Exemplo n.º 2
0
Arquivo: views.py Projeto: ThinkZ/pkyx
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)
Exemplo n.º 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="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)