diff options
Diffstat (limited to 'pyaggr3g470r')
-rw-r--r-- | pyaggr3g470r/templates/home.html | 34 | ||||
-rw-r--r-- | pyaggr3g470r/templates/unread.html | 34 | ||||
-rw-r--r-- | pyaggr3g470r/views.py | 11 |
3 files changed, 53 insertions, 26 deletions
diff --git a/pyaggr3g470r/templates/home.html b/pyaggr3g470r/templates/home.html index 0344263f..bf17356f 100644 --- a/pyaggr3g470r/templates/home.html +++ b/pyaggr3g470r/templates/home.html @@ -8,18 +8,30 @@ <a href="/articles/{{ feed.id }}"><i class="glyphicon glyphicon-th-list"></i></a> </div> </div> - {% for number in range(0, feed.articles|length-2, 3) %} - <div class="row"> - {% for n in range(number, number+3) %} - <div class="col-xs-6 col-sm-4 col-md-4"> - {% if feed.articles[n].readed %}<h3>{% else %}<h1>{% endif %} - <a href="/article/{{ feed.articles[n].id }}">{{ feed.articles[n].title }}</a><h2> - {% if feed.articles[n].readed %}</h3>{% else %}</h1>{% endif %} - <h6>{{ feed.articles[n].date }}</h6> + {% for number in range(0, feed.articles|length-(feed.articles|length % 3), 3) %} + <div class="row"> + {% for n in range(number, number+3) %} + <div class="col-xs-6 col-sm-4 col-md-4"> + {% if feed.articles[n].readed %}<h3>{% else %}<h1>{% endif %} + <a href="/article/{{ feed.articles[n].id }}">{{ feed.articles[n].title }}</a><h2> + {% if feed.articles[n].readed %}</h3>{% else %}</h1>{% endif %} + <h6>{{ feed.articles[n].date }}</h6> + </div> + {% endfor %} </div> - {% endfor %} - </div> - {% endfor %} + {% endfor %} + {% if feed.articles|length % 3 != 0 %} + <div class="row"> + {% for n in range(0, feed.articles|length % 3) %} + <div class="col-xs-6 col-sm-4 col-md-4"> + {% if feed.articles[n].readed %}<h3>{% else %}<h1>{% endif %} + <a href="/article/{{ feed.articles[n].id }}">{{ feed.articles[n].title }}</a><h2> + {% if feed.articles[n].readed %}</h3>{% else %}</h1>{% endif %} + <h6>{{ feed.articles[n].date }}</h6> + </div> + {% endfor %} + </div> + {% endif %} {% endfor %} </div><!-- /.container --> {% endblock %}
\ No newline at end of file diff --git a/pyaggr3g470r/templates/unread.html b/pyaggr3g470r/templates/unread.html index 0344263f..bf17356f 100644 --- a/pyaggr3g470r/templates/unread.html +++ b/pyaggr3g470r/templates/unread.html @@ -8,18 +8,30 @@ <a href="/articles/{{ feed.id }}"><i class="glyphicon glyphicon-th-list"></i></a> </div> </div> - {% for number in range(0, feed.articles|length-2, 3) %} - <div class="row"> - {% for n in range(number, number+3) %} - <div class="col-xs-6 col-sm-4 col-md-4"> - {% if feed.articles[n].readed %}<h3>{% else %}<h1>{% endif %} - <a href="/article/{{ feed.articles[n].id }}">{{ feed.articles[n].title }}</a><h2> - {% if feed.articles[n].readed %}</h3>{% else %}</h1>{% endif %} - <h6>{{ feed.articles[n].date }}</h6> + {% for number in range(0, feed.articles|length-(feed.articles|length % 3), 3) %} + <div class="row"> + {% for n in range(number, number+3) %} + <div class="col-xs-6 col-sm-4 col-md-4"> + {% if feed.articles[n].readed %}<h3>{% else %}<h1>{% endif %} + <a href="/article/{{ feed.articles[n].id }}">{{ feed.articles[n].title }}</a><h2> + {% if feed.articles[n].readed %}</h3>{% else %}</h1>{% endif %} + <h6>{{ feed.articles[n].date }}</h6> + </div> + {% endfor %} </div> - {% endfor %} - </div> - {% endfor %} + {% endfor %} + {% if feed.articles|length % 3 != 0 %} + <div class="row"> + {% for n in range(0, feed.articles|length % 3) %} + <div class="col-xs-6 col-sm-4 col-md-4"> + {% if feed.articles[n].readed %}<h3>{% else %}<h1>{% endif %} + <a href="/article/{{ feed.articles[n].id }}">{{ feed.articles[n].title }}</a><h2> + {% if feed.articles[n].readed %}</h3>{% else %}</h1>{% endif %} + <h6>{{ feed.articles[n].date }}</h6> + </div> + {% endfor %} + </div> + {% endif %} {% endfor %} </div><!-- /.container --> {% endblock %}
\ No newline at end of file diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index 359ae15d..fa406fe9 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -140,10 +140,13 @@ def favorites(): @app.route('/unread/', methods=['GET']) @login_required def unread(): - feeds = models.Feed.objects().filter(articles__readed=False) - unread_articles = models.Article.objects.filter(readed = False) - print len(feeds) - return render_template('unread.html', feeds=feeds) + feeds = models.Feed.objects() + result = [] + for feed in feeds: + feed.articles = [article for article in feed.articles if not article.readed] + if len(feed.articles) != 0: + result.append(feed) + return render_template('unread.html', feeds=result) @app.route('/management/', methods=['GET']) @login_required |