Beispiel #1
0
def order(order_id):
    o = Order.get(order_id)
    # mark all comments as read
    for c in o.comments:
        c.unread = False
        c.save()
    return render_template('order/order.html', o=o)
Beispiel #2
0
 def setUp(self):
     """
     Test setup
     """
     self.order = Order("order_number", "order_description", "order_price",
                        "size")
     self.orders_list = CustomerOrders()
Beispiel #3
0
def admin_order_set_status(order_id, new_status_code):
    if not current_user.is_admin:
        abort(403)  # access denied
    o = Order.get(order_id)
    if not OrderStatus.get(new_status_code):
        return abort(400)  # bad request
    o.status_id = new_status_code
    o.save()
    return redirect(url_for('admin_order', order_id=order_id))
Beispiel #4
0
def get_or_create_order(update, context):
    user_data = context.user_data
    if 'order_id' in user_data:
        order_id = user_data['order_id']
        order = Order.query.filter(Order.id == order_id).first()
    else:
        order = Order(telegram_id=update.message.from_user.id)
        db.session.add(order)
        db.session.commit()
        user_data['order_id'] = order.id
    return order
Beispiel #5
0
def admin_order_resolve(order_id):
    if not current_user.is_admin:
        abort(403)  # access denied
    o = Order.get(order_id)
    if not o:
        abort(404)
    if 'book_id' not in request.form:
        abort(400)
    o.status_id = 2  # resolved
    o.book_id = request.form['book_id']
    o.save()
    return redirect(url_for('admin_orders'))
Beispiel #6
0
def load_order_data(filename):

    headers = []

    csvfile = open(filename, "r")

    # Read in the headers/first row

    for header in csv.DictReader(csvfile,
                                 quotechar='"',
                                 delimiter=',',
                                 quoting=csv.QUOTE_ALL,
                                 skipinitialspace=True):
        headers.append(header)

    for row in headers:
        order = Order()
        date = row['created_at']
        date = datetime.strptime(date, "%Y-%m-%d %H:%M:%S.%f")
        sdate = datetime.strftime(date, '%d%m%Y')
        order.order_id = row['id']
        order.created_at = date
        order.vendor_id = row['vendor_id']
        order.customer_id = row['customer_id']
        try:
            db.session.add(order)
            db.session.commit()
        except Exception as err:
            db.session.rollback()
            print(err)
Beispiel #7
0
def comment_add(order_id):
    text = request.form['text']
    c = Comment()
    o = Order.get(order_id)
    if not o:
        abort(404)
    c.text = text
    c.order_id = order_id
    c.user_login = current_user.login
    c.save()
    if current_user.is_admin:
        return redirect(url_for('admin_order', order_id=order_id))
    return redirect(url_for('order', order_id=order_id))
Beispiel #8
0
def order_create():
    if request.method == 'GET':
        return render_template('order/create.html', model={})
    # POST
    validator = Order.get_input_validator()
    try:
        args = parser.parse(validator, request)
    except Exception as e:
        return render_template('order/create.html', error=str(e.data['exc'].arg_name), model=request.form)
    o = Order()
    o.author = args['author']
    o.name = args['name']
    o.year = args['year']
    o.user_login = current_user.login
    o.save()
    return redirect(url_for('orders'))
Beispiel #9
0
def admin_order(order_id):
    if not current_user.is_admin:
        abort(403)  # access denied
    o = Order.get(order_id)
    return render_template('admin/order.html', o=o)
Beispiel #10
0
def admin_orders():
    if not current_user.is_admin:
        abort(403)  # access denied
    ods = Order.get_all()
    return render_template('admin/orders.html', orders=ods)