aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r
diff options
context:
space:
mode:
Diffstat (limited to 'pyaggr3g470r')
-rw-r--r--pyaggr3g470r/templates/article.html4
-rw-r--r--pyaggr3g470r/views.py11
2 files changed, 13 insertions, 2 deletions
diff --git a/pyaggr3g470r/templates/article.html b/pyaggr3g470r/templates/article.html
index 51f7c485..315bb6f4 100644
--- a/pyaggr3g470r/templates/article.html
+++ b/pyaggr3g470r/templates/article.html
@@ -9,9 +9,9 @@
<h2><a href="{{ article.link }}">{{ article.title }}</a></h2>
<a href="/delete/{{ article.id }}"><i class="glyphicon glyphicon-remove" title="Delete this article"></i></a>
{% if article.like %}
- <i class="glyphicon glyphicon-star" title="One of your favorites"></i>
+ <a href="/like/{{ article.id }}"><i class="glyphicon glyphicon-star" title="One of your favorites"></i></a>
{% else %}
- <i class="glyphicon glyphicon-star-empty" title="Click if you like this article"></i>
+ <a href="/like/{{ article.id }}"><i class="glyphicon glyphicon-star-empty" title="Click if you like this article"></i></a>
{% endif %}
<h6>{{ article.date }}</h6>
</div>
diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py
index 79a53ca0..96d34aea 100644
--- a/pyaggr3g470r/views.py
+++ b/pyaggr3g470r/views.py
@@ -146,6 +146,17 @@ def mark_as_read():
models.Article.objects(readed=False).update(set__readed=True)
return redirect(url_for('home'))
+@app.route('/like/<article_id>', methods=['GET'])
+@login_required
+def like(article_id=None):
+ """
+ Mark or unmark an article as favorites.
+ """
+ #user = models.User.objects(email=g.user.email).first()
+ models.Article.objects(id=article_id).update(set__like= \
+ (not models.Article.objects(id=article_id).first().like))
+ return redirect("/article/"+article_id)
+
@app.route('/delete/<article_id>', methods=['GET'])
@login_required
def delete(article_id=None):
bgstack15