Example #1
0
def search():
    configuration = config.Config()
    if request.method == 'POST':
        categories = Category.get_filtered_categories(request.form)
    else:
        categories = Category.get_all_categories()

    return render_template('categories/search.html',
                           categories=categories,
                           configuration=configuration)
Example #2
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)
Example #3
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)
Example #4
0
    def __init__(self, iterable):
        self.name = iterable['name']
        self.description = iterable['description']
        self.price = iterable['price']
        self.sku = iterable['sku']
        self.is_regular = iterable['is_regular']
        self.category_id = iterable['category_id']

        self.id = self._get_article_id()
        self.on_branch_1 = self._get_stock_on_branch(iterable, 1)
        self.on_branch_2 = self._get_stock_on_branch(iterable, 2)
        self.stock = self._get_stock()

        self.category = Category.get_category_by_id(self.category_id)
Example #5
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)
Example #6
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)
Example #7
0
def delete(id):
    Category.delete_category(id)
    return redirect(url_for('categories.search'))