aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pyaggr3g470r/templates/admin/user.html4
-rw-r--r--pyaggr3g470r/templates/feeds.html2
-rw-r--r--pyaggr3g470r/views/feed.py5
-rw-r--r--pyaggr3g470r/views/views.py9
4 files changed, 14 insertions, 6 deletions
diff --git a/pyaggr3g470r/templates/admin/user.html b/pyaggr3g470r/templates/admin/user.html
index 317fef49..e50741ee 100644
--- a/pyaggr3g470r/templates/admin/user.html
+++ b/pyaggr3g470r/templates/admin/user.html
@@ -26,7 +26,7 @@
<th>{{ _('Name') }}</th>
<th>{{ _('Feed link') }}</th>
<th>{{ _('Site link') }}</th>
- <th>{{ _('Number of articles') }}</th>
+ <th>{{ _('(unread) articles') }}</th>
<th>{{ _('Actions') }}</th>
</tr>
</thead>
@@ -37,7 +37,7 @@
<td><a href="/feed/{{ feed.id }}">{{ feed.title }}</a></td>
<td>{{ feed.link }}</td>
<td>{{ feed.site_link }}</td>
- <td>{{ feed.articles.all()|count }}</td>
+ <td>( {{ unread_article_count.get(feed.id, 0) }} ) {{ article_count.get(feed.id, 0) }}</td>
<td>
<a href="{{ url_for("feed.feed", feed_id=feed.id) }}"><i class="glyphicon glyphicon-th-list" title="{{ _('Feed') }}"></i></a>
<a href="{{ url_for("feed.form", feed_id=feed.id) }}"><i class="glyphicon glyphicon-edit" title="{{ _('Edit this feed') }}"></i></a>
diff --git a/pyaggr3g470r/templates/feeds.html b/pyaggr3g470r/templates/feeds.html
index 4d4581d4..789decf5 100644
--- a/pyaggr3g470r/templates/feeds.html
+++ b/pyaggr3g470r/templates/feeds.html
@@ -30,7 +30,7 @@
</td>
<td><a href="{{ url_for("feed.feed", feed_id=feed.id) }}" {% if feed.description %}title="{{ feed.description }}"{% endif %}>{{ feed.title }}</a></td>
<td><a href="{{ feed.site_link }}">{{ feed.site_link }}</a></td>
- <td>{{ article_count[feed.id] }}</td>
+ <td>( {{ unread_article_count.get(feed.id, 0) }} ) {{ article_count.get(feed.id, 0) }}</td>
<td>
<a href="{{ url_for("home", feed_id=feed.id, filter_="all") }}"><i class="glyphicon glyphicon-th-list" title="{{ _('Articles') }}"></i></a>
<a href="{{ url_for("feed.form", feed_id=feed.id) }}"><i class="glyphicon glyphicon-edit" title="{{ _('Edit this feed') }}"></i></a>
diff --git a/pyaggr3g470r/views/feed.py b/pyaggr3g470r/views/feed.py
index f940e22d..d50d0883 100644
--- a/pyaggr3g470r/views/feed.py
+++ b/pyaggr3g470r/views/feed.py
@@ -23,9 +23,12 @@ feed_bp = Blueprint('feed', __name__, url_prefix='/feed')
@login_required
def feeds():
"Lists the subscribed feeds in a table."
+ art_contr = ArticleController(g.user.id)
return render_template('feeds.html',
feeds=FeedController(g.user.id).read(),
- article_count=ArticleController(g.user.id).count_by_feed())
+ unread_article_count=art_contr.count_by_feed(readed=False),
+ article_count=art_contr.count_by_feed(),
+ )
@feed_bp.route('/<int:feed_id>', methods=['GET'])
diff --git a/pyaggr3g470r/views/views.py b/pyaggr3g470r/views/views.py
index e0bd1dcb..a4e799cc 100644
--- a/pyaggr3g470r/views/views.py
+++ b/pyaggr3g470r/views/views.py
@@ -736,9 +736,14 @@ def user(user_id=None):
"""
See information about a user (stations, etc.).
"""
- user = User.query.filter(User.id == user_id).first()
+ user = UserController().get(id=user_id)
if user is not None:
- return render_template('/admin/user.html', user=user)
+ article_contr = ArticleController(user_id)
+ return render_template('/admin/user.html', user=user,
+ article_count=article_contr.count_by_feed(),
+ unread_article_count=article_contr.count_by_feed(readed=False),
+ )
+
else:
flash(gettext('This user does not exist.'), 'danger')
return redirect(redirect_url())
bgstack15