@bp_rack.route('/add.html', methods=['GET', 'POST'])
@login_required
@permission_rack_section_add.require(http_exception=403)
def add():
    '\n    创建货架\n    :return:\n    '
    template_name = 'rack/add.html'
    document_info = DOCUMENT_INFO.copy()
    document_info['TITLE'] = _('rack add')
    form = RackAddForm(request.form)
    form.warehouse_id.choices = get_warehouse_choices(option_type='create')
    if (request.method == 'GET'):
        return render_template(template_name, form=form, **document_info)
    if (request.method == 'POST'):
        if (not form.validate_on_submit()):
            flash(_('Add Failure'), 'danger')
            return render_template(template_name, form=form, **document_info)
        current_time = datetime.utcnow()
        rack_data = {'warehouse_id': form.warehouse_id.data, 'name': form.name.data, 'create_time': current_time, 'update_time': current_time}
        result = add_rack(rack_data)
        if result:
            flash(_('Add Success'), 'success')
            return redirect((request.args.get('next') or url_for('rack.lists')))
        else:
            flash(_('Add Failure'), 'danger')
            return render_template(template_name, form=form, **document_info)
创建货架
:return:
@bp_rack.route('/add.html', methods=['GET', 'POST'])
@login_required
@permission_rack_section_add.require(http_exception=403)
def add():
    '\n    创建货架\n    :return:\n    '
    template_name = 'rack/add.html'
    document_info = DOCUMENT_INFO.copy()
    document_info['TITLE'] = _('rack add')
    form = RackAddForm(request.form)
    form.warehouse_id.choices = get_warehouse_choices(option_type='create')
    if (request.method == 'GET'):
        return render_template(template_name, form=form, **document_info)
    if (request.method == 'POST'):
        if (not form.validate_on_submit()):
            flash(_('Add Failure'), 'danger')
            return render_template(template_name, form=form, **document_info)
        current_time = datetime.utcnow()
        rack_data = {'warehouse_id': form.warehouse_id.data, 'name': form.name.data, 'create_time': current_time, 'update_time': current_time}
        result = add_rack(rack_data)
        if result:
            flash(_('Add Success'), 'success')
            return redirect((request.args.get('next') or url_for('rack.lists')))
        else:
            flash(_('Add Failure'), 'danger')
            return render_template(template_name, form=form, **document_info)