def category_new(cat_type): check_cat_type(cat_type) lang = 'en' category = Category(lang=lang) category.status = 'edit' category.cat_type = cat_type db.session.add(category) db.session.commit() return redirect(url_for_admin('category_edit', id=category.category_id, cat_type=cat_type))
def category_trans(id, cat_type): lang = get_admin_lang() category = Category.query.filter_by(category_id=id, lang='en').first() if not category: abort(404) exists = Category.query.filter_by(category_id=category.category_id, lang=lang).first() if exists: abort(403) trans = Category(lang=lang) trans.status = 'edit' trans.category_id = id trans.cat_type = cat_type db.session.add(trans) db.session.commit() return redirect(url_for_admin('category_edit', id=id, cat_type=cat_type))