diff options
author | François Schmidts <francois.schmidts@gmail.com> | 2014-06-08 17:47:42 +0200 |
---|---|---|
committer | François Schmidts <francois.schmidts@gmail.com> | 2014-06-10 20:24:30 +0200 |
commit | cb6a8d8b53bb27755eb9bc040f86a361636d4c6a (patch) | |
tree | fb695d763d8fc0b33e512aed8f1442e522d8956e | |
parent | fixes #7 (diff) | |
download | newspipe-cb6a8d8b53bb27755eb9bc040f86a361636d4c6a.tar.gz newspipe-cb6a8d8b53bb27755eb9bc040f86a361636d4c6a.tar.bz2 newspipe-cb6a8d8b53bb27755eb9bc040f86a361636d4c6a.zip |
adding the capacity to mark articles as unread
-rw-r--r-- | pyaggr3g470r/templates/article.html | 1 | ||||
-rw-r--r-- | pyaggr3g470r/templates/home.html | 5 | ||||
-rw-r--r-- | pyaggr3g470r/templates/layout.html | 4 | ||||
-rw-r--r-- | pyaggr3g470r/templates/unread.html | 3 | ||||
-rw-r--r-- | pyaggr3g470r/views.py | 26 |
5 files changed, 25 insertions, 14 deletions
diff --git a/pyaggr3g470r/templates/article.html b/pyaggr3g470r/templates/article.html index 83e23b34..1ee86948 100644 --- a/pyaggr3g470r/templates/article.html +++ b/pyaggr3g470r/templates/article.html @@ -14,6 +14,7 @@ {% else %} <a href="/like/{{ article.id }}"><i class="glyphicon glyphicon-star-empty" title="{{ _('Click if you like this article') }}"></i></a> {% endif %} + <a href="/mark_as/unread/article/{{ article.id }}"><i class="glyphicon glyphicon-unchecked" title="{{ _('Mark this article as unread') }}"></i></a> <h6>{{ article.date | datetime }}</h6> </div> <div class="jumbotron"> diff --git a/pyaggr3g470r/templates/home.html b/pyaggr3g470r/templates/home.html index c1663997..297e0214 100644 --- a/pyaggr3g470r/templates/home.html +++ b/pyaggr3g470r/templates/home.html @@ -25,7 +25,7 @@ <div class="col-md-6 col-md-offset-3"> <h1>{{ feed.title|safe }} {% if feed.nb_unread != 0 %} - <a href="/unread/{{ feed.id }}" title="Unread articles"><span class="badge">{{ feed.nb_unread }}</span></a> + <a href="/unread/{{ feed.id }}" title="Unread articles"><span class="badge">{{ feed.nb_unread }}</span></a> {% endif %}</h1> <a href="/articles/{{ feed.id }}/100"><i class="glyphicon glyphicon-th-list" title="{{ _('More articles') }}"></i></a> <a href="/feed/{{ feed.id }}"><i class="glyphicon glyphicon-info-sign" title="{{ _('Details') }}"></i></a> @@ -34,8 +34,9 @@ <a href="/fetch/{{ feed.id }}"><i class="glyphicon glyphicon-cloud-download" title="{{ _('Fetch this feed') }}"></i></a> {% endif %} {% if feed.nb_unread != 0 %} - <a href="/mark_as_read/{{ feed.id }}"><i class="glyphicon glyphicon-check" title="{{ _('Mark all as read') }}"></i></a> + <a href="/mark_as/read/feed/{{ feed.id }}"><i class="glyphicon glyphicon-check" title="{{ _('Mark all feed as read') }}"></i></a> {% endif %} + <a href="/mark_as/unread/feed/{{ feed.id }}"><i class="glyphicon glyphicon-unchecked" title="{{ _('Mark all feed as unread') }}"></i></a> </div> </div> {% for number in range(0, feed.articles.all()|count-(feed.articles.all()|count % 3), 3) %} diff --git a/pyaggr3g470r/templates/layout.html b/pyaggr3g470r/templates/layout.html index d1040422..8fc88d74 100644 --- a/pyaggr3g470r/templates/layout.html +++ b/pyaggr3g470r/templates/layout.html @@ -27,7 +27,7 @@ deployed on Heroku or on a traditional server." /> height: 0; } ul.affix { - position: fixed; + position: fixed; top: 0px; } ul.affix-top { @@ -102,7 +102,7 @@ deployed on Heroku or on a traditional server." /> <a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ _('Articles') }} <b class="caret"></b></a> <ul class="dropdown-menu"> <li><a accesskey="r" href="/fetch/">{{ _('Fetch') }}</a></li> - <li><a href="/mark_as_read/">{{ _('Mark all as read') }}</a></li> + <li><a href="/mark_as/read/">{{ _('Mark all as read') }}</a></li> <li role="presentation" class="divider"></li> <li><a href="/create_feed/">{{ _('Add a feed') }}</a></li> </ul> diff --git a/pyaggr3g470r/templates/unread.html b/pyaggr3g470r/templates/unread.html index 6c5c5d08..cdfb0dfe 100644 --- a/pyaggr3g470r/templates/unread.html +++ b/pyaggr3g470r/templates/unread.html @@ -16,7 +16,8 @@ <a href="/articles/{{ feed.id }}/100"><i class="glyphicon glyphicon-th-list" title="{{ _('More articles') }}"></i></a> <a href="/feed/{{ feed.id }}"><i class="glyphicon glyphicon-info-sign" title="{{ _('Details') }}"></i></a> <a href="/edit_feed/{{ feed.id }}"><i class="glyphicon glyphicon-edit" title="{{ _('Edit this feed') }}"></i></a> - <a href="/mark_as_read/{{ feed.id }}"><i class="glyphicon glyphicon-check" title="{{ _('Mark all as read') }}"></i></a> + <a href="/mark_as/read/feed/{{ feed.id }}"><i class="glyphicon glyphicon-check" title="{{ _('Mark all feed as read') }}"></i></a> + <a href="/mark_as/unread/feed/{{ feed.id }}"><i class="glyphicon glyphicon-unchecked" title="{{ _('Mark all feed as unread') }}"></i></a> <h3>{{ feed.articles.all()|length }} {{ _('unread articles') }}.</h3> </div> </div> diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index e4668f54..1f3e16d7 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -312,23 +312,31 @@ def article(article_id=None): return redirect(redirect_url()) -@app.route('/mark_as_read/', methods=['GET']) -@app.route('/mark_as_read/<int:feed_id>', methods=['GET']) +@app.route('/mark_as/<string:new_value>', methods=['GET']) +@app.route('/mark_as/<string:new_value>/feed/<int:feed_id>', methods=['GET']) +@app.route('/mark_as/<string:new_value>/article/<int:article_id>', methods=['GET']) @login_required @feed_access_required -def mark_as_read(feed_id=None): +def mark_as(new_value='read', feed_id=None, article_id=None): """ Mark all unreaded articles as read. """ + readed = new_value == 'read' + articles = Article.query.filter(Article.user_id == g.user.id) if feed_id is not None: - Article.query.filter(Article.user_id == g.user.id, Article.feed_id == feed_id, - Article.readed == False).update({"readed": True}) - flash(gettext('Articles marked as read.'), 'info') + articles = articles.filter(Article.feed_id == feed_id) + message = 'Feed marked as %s.' + elif article_id is not None: + articles = articles.filter(Article.id == article_id) + message = 'Article marked as %s.' else: - Article.query.filter(Article.user_id == g.user.id, Article.readed == False).update({"readed": True}) - flash(gettext("All articles marked as read"), 'info') + message = 'All article marked as %s.' + articles.filter(Article.readed == (not readed)).update({"readed": readed}) + flash(gettext(message % new_value), 'info') db.session.commit() - return redirect(redirect_url()) + if readed: + return redirect(redirect_url()) + return redirect('/#%d' % articles.first().feed_id) @app.route('/like/<int:article_id>', methods=['GET']) @login_required |