aboutsummaryrefslogtreecommitdiff
path: root/src/web/views
diff options
context:
space:
mode:
Diffstat (limited to 'src/web/views')
-rw-r--r--src/web/views/feed.py26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/web/views/feed.py b/src/web/views/feed.py
index 2a9b2da8..68d8765a 100644
--- a/src/web/views/feed.py
+++ b/src/web/views/feed.py
@@ -17,7 +17,8 @@ from web import utils
from web.lib.view_utils import etag_match
from web.lib.feed_utils import construct_feed_from
from web.forms import AddFeedForm
-from web.controllers import FeedController, ArticleController
+from web.controllers import (CategoryController, FeedController,
+ ArticleController)
feeds_bp = Blueprint('feeds', __name__, url_prefix='/feeds')
feed_bp = Blueprint('feed', __name__, url_prefix='/feed')
@@ -42,6 +43,9 @@ def feed(feed_id=None):
"Presents detailed information about a feed."
feed = FeedController(g.user.id).get(id=feed_id)
word_size = 6
+ category = None
+ if feed.category_id:
+ category = CategoryController(g.user.id).get(id=feed.category_id)
articles = ArticleController(g.user.id) \
.read(feed_id=feed_id) \
.order_by(desc("Article.date")).all()
@@ -65,7 +69,7 @@ def feed(feed_id=None):
head_titles=[utils.clear_string(feed.title)],
feed=feed, tag_cloud=tag_cloud,
first_post_date=first_article,
- end_post_date=last_article,
+ end_post_date=last_article, category=category,
average=average, delta=delta, elapsed=elapsed)
@@ -149,18 +153,23 @@ def update(action, feed_id=None):
@etag_match
def form(feed_id=None):
action = gettext("Add a feed")
+ categories = CategoryController(g.user.id).read()
head_titles = [action]
if feed_id is None:
+ form = AddFeedForm()
+ form.set_category_choices(categories)
return render_template('edit_feed.html', action=action,
- head_titles=head_titles, form=AddFeedForm())
+ head_titles=head_titles, form=form)
feed = FeedController(g.user.id).get(id=feed_id)
+ form = AddFeedForm(obj=feed)
+ form.set_category_choices(categories)
action = gettext('Edit feed')
head_titles = [action]
if feed.title:
head_titles.append(feed.title)
return render_template('edit_feed.html', action=action,
- head_titles=head_titles,
- form=AddFeedForm(obj=feed), feed=feed)
+ head_titles=head_titles, categories=categories,
+ form=form, feed=feed)
@feed_bp.route('/create', methods=['POST'])
@@ -169,6 +178,7 @@ def form(feed_id=None):
def process_form(feed_id=None):
form = AddFeedForm()
feed_contr = FeedController(g.user.id)
+ form.set_category_choices(CategoryController(g.user.id).read())
if not form.validate():
return render_template('edit_feed.html', form=form)
@@ -179,7 +189,9 @@ def process_form(feed_id=None):
# Edit an existing feed
feed_attr = {'title': form.title.data, 'enabled': form.enabled.data,
'link': form.link.data, 'site_link': form.site_link.data,
- 'filters': []}
+ 'filters': [], 'category_id': form.category_id.data}
+ if not feed_attr['category_id']:
+ del feed_attr['category_id']
for filter_attr in ('type', 'pattern', 'action on', 'action'):
for i, value in enumerate(
@@ -195,7 +207,7 @@ def process_form(feed_id=None):
return redirect(url_for('feed.form', feed_id=feed_id))
# Create a new feed
- new_feed = FeedController(g.user.id).create(**feed_attr)
+ new_feed = feed_contr.create(**feed_attr)
flash(gettext('Feed %(feed_title)r successfully created.',
feed_title=new_feed.title), 'success')
bgstack15