From 6657cc1c91b823e1017fb35e2bab18ffe9034dff Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Mon, 9 Jul 2018 16:13:31 +0200 Subject: [PATCH] [Bugfix] Fix user follow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * The link didn’t have a closing tag * The whole mechanism didn’t work I probably submitted a previous patch… --- calsocial/__init__.py | 16 ++++++++-------- calsocial/templates/profile-details.html | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/calsocial/__init__.py b/calsocial/__init__.py index 8af9ebf..a1f0b31 100644 --- a/calsocial/__init__.py +++ b/calsocial/__init__.py @@ -259,9 +259,9 @@ class CalendarSocialApp(Flask): from .models import Profile, User - profile = current_user.profile - - if profile is None: + try: + profile = Profile.query.join(User).filter(User.username == username).one() + except NoResultFound: abort(404) return render_template('profile-details.html', profile=profile) @@ -274,14 +274,14 @@ class CalendarSocialApp(Flask): from .models import db, Profile, User, UserFollow, Notification, NotificationAction - profile = current_user.profile - - if profile is None: + try: + profile = Profile.query.join(User).filter(User.username == username).one() + except NoResultFound: abort(404) if profile.user != current_user: - follow = UserFollow(follower_id=current_user.profile, - followed_id=profile, + follow = UserFollow(follower=current_user.profile, + followed=profile, accepted_at=datetime.utcnow()) db.session.add(follow) diff --git a/calsocial/templates/profile-details.html b/calsocial/templates/profile-details.html index 75db8d8..07ea66d 100644 --- a/calsocial/templates/profile-details.html +++ b/calsocial/templates/profile-details.html @@ -6,7 +6,7 @@ @{{ profile.user.username}} {% if profile.user != current_user %} -{% trans %}Follow{% endtrans %} +{% trans %}Follow{% endtrans %} {% endif %}