Skip to content

Commit

Permalink
rename timeline to feed
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Dec 26, 2021
1 parent aa8172b commit 2cec1c7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions api/posts.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,23 @@ def delete(id):
return '', 204


@posts.route('/users/<int:id>/timeline', methods=['GET'])
@posts.route('/users/<int:id>/feed', methods=['GET'])
@authenticate(token_auth)
@paginated_response(posts_schema, order_by=Post.timestamp,
order_direction='desc', model_from_statement=Post,
pagination_schema=DateTimePaginationSchema)
def timeline(id):
"""Retrieve the user's post timeline"""
def feed(id):
"""Retrieve the user's post feed"""
user = db.session.get(User, id) or abort(404)
return user.followed_posts_select().order_by(Post.timestamp.desc())


@posts.route('/users/me/timeline', methods=['GET'])
@posts.route('/users/me/feed', methods=['GET'])
@authenticate(token_auth)
@paginated_response(posts_schema, order_by=Post.timestamp,
order_direction='desc', model_from_statement=Post,
pagination_schema=DateTimePaginationSchema)
def my_timeline():
"""Retrieve the logged in user's post timeline"""
def my_feed():
"""Retrieve the logged in user's post feed"""
user = token_auth.current_user()['user']
return user.followed_posts_select().order_by(Post.timestamp.desc())
6 changes: 3 additions & 3 deletions tests/test_posts.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_delete_post(self):
rv = self.client.get(f'/api/posts/{id}')
assert rv.status_code == 404

def test_post_timeline(self):
def test_post_feed(self):
user1 = db.session.get(User, 1)
user2 = User(username='susan', email='[email protected]',
password='dog')
Expand All @@ -75,8 +75,8 @@ def test_post_timeline(self):
db.session.add_all([post1, post2, post3])
db.session.commit()

rv1 = self.client.get('/api/users/me/timeline')
rv2 = self.client.get('/api/users/1/timeline')
rv1 = self.client.get('/api/users/me/feed')
rv2 = self.client.get('/api/users/1/feed')
for rv in [rv1, rv2]:
assert rv.status_code == 200
assert rv.json['pagination']['total'] == 3
Expand Down

0 comments on commit 2cec1c7

Please sign in to comment.