From 9a9b5c19d8c07026b104ed81838145454bfa9fc9 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Sun, 12 Apr 2015 17:03:20 +0200 Subject: It is now possible to add a new feed from any page via a dropdown menu. --- pyaggr3g470r/views/feed.py | 5 ++++- pyaggr3g470r/views/views.py | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'pyaggr3g470r/views') diff --git a/pyaggr3g470r/views/feed.py b/pyaggr3g470r/views/feed.py index e4c0dc9a..af43d6f0 100644 --- a/pyaggr3g470r/views/feed.py +++ b/pyaggr3g470r/views/feed.py @@ -134,6 +134,8 @@ def form(feed_id=None): if request.method == 'POST': if not form.validate(): + print(dir(form)) + print("oups") return render_template('edit_feed.html', form=form) existing_feeds = list(feed_contr.read(link=form.link.data)) if existing_feeds and feed_id is None: @@ -141,8 +143,8 @@ def form(feed_id=None): "warning") return redirect(url_for('feed.form', feed_id=existing_feeds[0].id)) - # Edit an existing feed + print("new...") if feed_id is not None: feed_contr.update({'id': feed_id}, {'title': form.title.data, @@ -154,6 +156,7 @@ def form(feed_id=None): return redirect(url_for('feed.form', feed_id=feed_id)) # Create a new feed + print("new feed") new_feed = FeedController(g.user.id).create( title=form.title.data, description="", diff --git a/pyaggr3g470r/views/views.py b/pyaggr3g470r/views/views.py index e06e1a9d..06b234cd 100644 --- a/pyaggr3g470r/views/views.py +++ b/pyaggr3g470r/views/views.py @@ -138,6 +138,16 @@ def get_timezone(): except: return conf.TIME_ZONE["en"] +@app.context_processor +def inject_feed_form(): + """ + Injects the 'AddFeedForm' objects in all templates. + + Context processors run before the template is rendered and have the + ability to inject new values into the template context. + """ + return dict(create_feed_form=AddFeedForm()) + # # Views. # -- cgit