forked from gergely/calendar-social
Add test for following a user through the web UI
This commit is contained in:
@@ -300,11 +300,12 @@ class CalendarSocialApp(Flask):
|
||||
|
||||
@staticmethod
|
||||
@route('/profile/@<string:username>/follow')
|
||||
@login_required
|
||||
def follow_user(username):
|
||||
"""View for following a user
|
||||
"""
|
||||
|
||||
from .models import db, Profile, User, UserFollow, Notification, NotificationAction
|
||||
from .models import db, Profile, User
|
||||
|
||||
try:
|
||||
profile = Profile.query.join(User).filter(User.username == username).one()
|
||||
@@ -312,16 +313,7 @@ class CalendarSocialApp(Flask):
|
||||
abort(404)
|
||||
|
||||
if profile.user != current_user:
|
||||
follow = UserFollow(follower=current_user.profile,
|
||||
followed=profile,
|
||||
accepted_at=datetime.utcnow())
|
||||
db.session.add(follow)
|
||||
|
||||
notification = Notification(profile=profile,
|
||||
actor=current_user.profile,
|
||||
item=profile,
|
||||
action=NotificationAction.follow)
|
||||
db.session.add(notification)
|
||||
profile.follow(follower=current_user.profile)
|
||||
|
||||
db.session.commit()
|
||||
|
||||
|
Reference in New Issue
Block a user