diff options
author | François Schmidts <francois.schmidts@gmail.com> | 2015-10-12 22:36:01 +0200 |
---|---|---|
committer | François Schmidts <francois.schmidts@gmail.com> | 2016-01-26 23:46:32 +0100 |
commit | 2c0e17cb977a1e8782799b337df8b1583d019906 (patch) | |
tree | 75563e440e9eac14950fa1a71a83e64df20e52d0 /pyaggr3g470r/views/category.py | |
parent | fixing sqlalchemy resolving warning (diff) | |
download | newspipe-2c0e17cb977a1e8782799b337df8b1583d019906.tar.gz newspipe-2c0e17cb977a1e8782799b337df8b1583d019906.tar.bz2 newspipe-2c0e17cb977a1e8782799b337df8b1583d019906.zip |
bootstraping react
Diffstat (limited to 'pyaggr3g470r/views/category.py')
-rw-r--r-- | pyaggr3g470r/views/category.py | 86 |
1 files changed, 0 insertions, 86 deletions
diff --git a/pyaggr3g470r/views/category.py b/pyaggr3g470r/views/category.py deleted file mode 100644 index 027a800f..00000000 --- a/pyaggr3g470r/views/category.py +++ /dev/null @@ -1,86 +0,0 @@ -from flask import g, Blueprint, render_template, flash, redirect, url_for -from flask.ext.babel import gettext -from flask.ext.login import login_required - -from pyaggr3g470r.forms import CategoryForm -from pyaggr3g470r.lib.utils import redirect_url -from pyaggr3g470r.lib.view_utils import etag_match -from pyaggr3g470r.controllers \ - import ArticleController, FeedController, CategoryController - -categories_bp = Blueprint('categories', __name__, url_prefix='/categories') -category_bp = Blueprint('category', __name__, url_prefix='/category') - - -@categories_bp.route('/', methods=['GET']) -@login_required -@etag_match -def list_(): - "Lists the subscribed feeds in a table." - art_contr = ArticleController(g.user.id) - return render_template('categories.html', - categories=list(CategoryController(g.user.id).read()), - feeds_count=FeedController(g.user.id).count_by_category(), - unread_article_count=art_contr.count_by_category(readed=False), - article_count=art_contr.count_by_category()) - - -@category_bp.route('/create', methods=['GET']) -@category_bp.route('/edit/<int:category_id>', methods=['GET']) -@login_required -@etag_match -def form(category_id=None): - action = gettext("Add a category") - head_titles = [action] - if category_id is None: - return render_template('edit_category.html', action=action, - head_titles=head_titles, form=CategoryForm()) - category = CategoryController(g.user.id).get(id=category_id) - action = gettext('Edit category') - head_titles = [action] - if category.name: - head_titles.append(category.name) - return render_template('edit_category.html', action=action, - head_titles=head_titles, category=category, - form=CategoryForm(obj=category)) - - -@category_bp.route('/delete/<int:category_id>', methods=['GET']) -@login_required -def delete(category_id=None): - category = CategoryController(g.user.id).delete(category_id) - flash(gettext("Category %(category_name)s successfully deleted.", - category_name=category.name), 'success') - return redirect(redirect_url()) - - -@category_bp.route('/create', methods=['POST']) -@category_bp.route('/edit/<int:category_id>', methods=['POST']) -@login_required -def process_form(category_id=None): - form = CategoryForm() - cat_contr = CategoryController(g.user.id) - - if not form.validate(): - return render_template('edit_category.html', form=form) - existing_cats = list(cat_contr.read(name=form.name.data)) - if existing_cats and category_id is None: - flash(gettext("Couldn't add category: already exists."), "warning") - return redirect(url_for('category.form', - category_id=existing_cats[0].id)) - # Edit an existing category - category_attr = {'name': form.name.data} - - if category_id is not None: - cat_contr.update({'id': category_id}, category_attr) - flash(gettext('Category %(cat_name)r successfully updated.', - cat_name=category_attr['name']), 'success') - return redirect(url_for('category.form', category_id=category_id)) - - # Create a new category - new_category = cat_contr.create(**category_attr) - - flash(gettext('Category %(category_name)r successfully created.', - category_name=new_category.name), 'success') - - return redirect(url_for('category.form', category_id=new_category.id)) |