예제 #1
0
def order_delete(order_id):
    order = OrderModel.find_by_id(order_id)

    if order:
        order.delete_from_db()

        return redirect(url_for("order.order_list"))
예제 #2
0
def post_create(order_id):

    order = OrderModel.find_by_id(order_id)
    form = PostCreateForm()

    if form.validate_on_submit():
        post = TrackingModel(message=form.message.data,
                             order_id=order_id,
                             staff_id=form.staff_id.data,
                             user_id=form.user_id.data)
        post.save_to_db()

        if form.attachment.data:

            storage_filename = save_attachment(form.attachment.data, post.id)

            attachment = AttachmentModel(attachment_name=storage_filename,
                                         track_log_id=post.id)
            attachment.save_to_db()

        return redirect(url_for("order.order_info", order_id=order_id))

    if is_user(current_user):
        form.staff_id.data = order.staff_id
        form.user_id.data = current_user.id
    else:
        form.user_id.data = order.user_id
        form.staff_id.data = current_user.id
    return render_template("post_create.html", form=form)
예제 #3
0
def order_info(order_id):

    order = OrderModel.find_by_id(order_id)

    page = request.args.get("page", 1, type=int)

    posts = TrackingModel.find_by_order_id(order_id).paginate(page=page,
                                                              per_page=10)

    return render_template("order_info.html", order=order, posts=posts)
예제 #4
0
def order_update(order_id):

    order = OrderModel.find_by_id(order_id)

    form = OrderUpdateForm()

    if form.validate_on_submit():
        order.name = form.name.data
        order.staff_id = form.staff_id.data
        order.save_to_db()
        return redirect(url_for("order.order_info", order_id=order.id))

    form.name.data = order.name
    form.staff_id.data = order.staff_id
    return render_template("order_update.html", form=form)