Пример #1
0
def checkout():
    sale = Sale(request.form)
    configuration = config.Config()
    cart = ShoppingCart()
    cart_items = cart.cart_items
    clients = Client.get_all_clients()
    branchId = sale.branchId
    if request.form['Discount'] is not '':
        sale.apply_discount()

    if sale.is_valid(branchId):
        sale.create_sale(cart_items, branchId)
        cart.update_cart_items_stock(branchId)
        cart.clear_cart()
        sale.save_sale_ticket(cart_items)
        sale.print_sale_ticket(cart_items)
        Alert.raise_success_alert('Sale Created')
        return render_template('cart/checkout.html',
                               sale=sale,
                               configuration=configuration)

    return render_template('cart/info.html',
                           cart=cart,
                           cart_items=cart_items,
                           clients=clients,
                           configuration=configuration)
Пример #2
0
def create():
    configuration = config.Config()
    if request.method == 'POST':
        user = User(request.form)
        if user.is_valid():
            user.create_user()
            Alert.raise_success_alert('User Created')

    return render_template('users/create.html', configuration=configuration)
Пример #3
0
def create():
    configuration = config.Config()
    if request.method == 'POST':
        client = Client(request.form)
        if client.is_valid_create():
            client.create_client()
            Alert.raise_success_alert('Client Created')

    return render_template('clients/create.html', configuration=configuration)
Пример #4
0
def create():
    configuration = config.Config()
    if request.method == 'POST':
        category = Category(request.form)
        if category.is_valid():
            category.create_category()
            Alert.raise_success_alert('Category Created')

    return render_template('categories/create.html',
                           configuration=configuration)
Пример #5
0
def update(id):
    configuration = config.Config()
    if request.method == 'POST':
        user = User(request.form)
        user.update_user(id)
        Alert.raise_success_alert('User Updated')

    else:
        user = User.get_user_by_id(id)

    return render_template('users/update.html', user=user, configuration=configuration)
Пример #6
0
def create():
    configuration = config.Config()
    if request.method == 'POST':
        article = Article(request.form)
        if article._is_valid():
            article.create_article()
            Alert.raise_success_alert('Article Created')
    categories = Category.get_all_categories()

    return render_template('articles/create.html',
                           categories=categories,
                           configuration=configuration)
Пример #7
0
def update(id):
    configuration = config.Config()
    if request.method == 'POST':
        client = Client(request.form)
        if client.is_valid_update():
            client.update_client(id)
            Alert.raise_success_alert('Client Updated')
    else:
        client = Client.get_client_by_id(id)

    return render_template('clients/update.html',
                           client=client,
                           configuration=configuration)
Пример #8
0
def update(id):
    configuration = config.Config()
    if request.method == 'POST':
        category = Category(request.form)
        if category.is_valid():
            category.update_category(id)
            Alert.raise_success_alert('Category Updated')
    else:
        category = Category.get_category_by_id(id)

    return render_template('categories/update.html',
                           category=category,
                           configuration=configuration)
Пример #9
0
def update(id):
    configuration = config.Config()
    article = Article.get_article_by_id(id)

    if request.method == 'POST':
        article = Article(request.form)
        article.update_article(id)
        Alert.raise_success_alert('Article Updated')

    categories = Category.get_all_categories()
    return render_template('articles/update.html',
                           article=article,
                           categories=categories,
                           configuration=configuration)