aboutsummaryrefslogtreecommitdiff
path: root/src/web/views
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2016-09-20 14:48:25 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2016-09-20 14:48:25 +0200
commit8bb831a4c3ce3a2e9c0d61a5a058db87a9e408a0 (patch)
treed2f2eb71f19808ea5f56f419595279658fc95035 /src/web/views
parentlazy loading of the translation (diff)
downloadnewspipe-8bb831a4c3ce3a2e9c0d61a5a058db87a9e408a0.tar.gz
newspipe-8bb831a4c3ce3a2e9c0d61a5a058db87a9e408a0.tar.bz2
newspipe-8bb831a4c3ce3a2e9c0d61a5a058db87a9e408a0.zip
Draft for a public user profile page.
Diffstat (limited to 'src/web/views')
-rw-r--r--src/web/views/user.py25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/web/views/user.py b/src/web/views/user.py
index 229530d1..bd12010c 100644
--- a/src/web/views/user.py
+++ b/src/web/views/user.py
@@ -18,6 +18,22 @@ users_bp = Blueprint('users', __name__, url_prefix='/users')
user_bp = Blueprint('user', __name__, url_prefix='/user')
+@user_bp.route('/<string:nickname>', methods=['GET'])
+def profile_public(nickname=None):
+ """
+ Display the public profile of the user.
+ """
+ user_contr = UserController()
+ user = user_contr.get(nickname=nickname)
+ if not user.is_public_profile:
+ return redirect(url_for('home'))
+ art_contr = ArticleController(user.id)
+ return render_template('profile_public.html',
+ user=user,
+ feeds=user.feeds,
+ unread_article_count=art_contr.count_by_category(readed=False),
+ article_count=art_contr.count_by_category())
+
@user_bp.route('/management', methods=['GET', 'POST'])
@login_required
def management():
@@ -80,10 +96,11 @@ def profile():
if request.method == 'POST':
if form.validate():
user_contr.update({'id': current_user.id},
- {'nickname': form.nickname.data,
- 'email': form.email.data,
- 'password': form.password.data,
- 'refresh_rate': form.refresh_rate.data})
+ {'nickname': form.nickname.data,
+ 'email': form.email.data,
+ 'password': form.password.data,
+ 'refresh_rate': form.refresh_rate.data,
+ 'is_public_profile': form.is_public_profile.data})
flash(gettext('User %(nick)s successfully updated',
nick=user.nickname), 'success')
bgstack15