Browse Source

Make bookmark page "empty" messages more specific

Saying "posts" when the user might have bookmarks of the other type
(topics/comments) wasn't quite right, so this just makes it more
specific and fixes up the related post_type code a little.
merge-requests/51/head
Deimos 6 years ago
parent
commit
85a0273d20
  1. 14
      tildes/tildes/templates/bookmarks.jinja2
  2. 8
      tildes/tildes/views/bookmarks.py

14
tildes/tildes/templates/bookmarks.jinja2

@ -12,10 +12,10 @@
<div class="listing-options"> <div class="listing-options">
<menu class="tab tab-listing-order"> <menu class="tab tab-listing-order">
<li class="tab-item{{' active' if (post_type == 'topic' or not post_type) else ''}}">
<li class="tab-item{{ ' active' if post_type == 'topic' }}">
<a href="{{ request.current_listing_normal_url({'type': 'topic'}) }}">Topics</a> <a href="{{ request.current_listing_normal_url({'type': 'topic'}) }}">Topics</a>
</li> </li>
<li class="tab-item{{ ' active' if post_type == 'comment' else ''}}">
<li class="tab-item{{ ' active' if post_type == 'comment' }}">
<a href="{{ request.current_listing_normal_url({'type': 'comment'}) }}">Comments</a> <a href="{{ request.current_listing_normal_url({'type': 'comment'}) }}">Comments</a>
</li> </li>
</menu> </menu>
@ -35,7 +35,7 @@
{% endfor %} {% endfor %}
</ol> </ol>
{% if post_type and (posts.has_prev_page or posts.has_next_page) %}
{% if posts.has_prev_page or posts.has_next_page %}
<div class="pagination"> <div class="pagination">
{% if posts.has_prev_page %} {% if posts.has_prev_page %}
<a class="page-item btn" id="prev-page" <a class="page-item btn" id="prev-page"
@ -52,7 +52,13 @@
{% endif %} {% endif %}
{% else %} {% else %}
<div class="empty"> <div class="empty">
<h2 class="empty-title">You haven't bookmarked any posts</h2>
<h2 class="empty-title">
{% if post_type == 'topic' %}
You haven't bookmarked any topics
{% elif post_type == 'comment' %}
You haven't bookmarked any comments
{% endif %}
</h2>
</div> </div>
{% endif %} {% endif %}

8
tildes/tildes/views/bookmarks.py

@ -17,7 +17,11 @@ from tildes.schemas.listing import PaginatedListingSchema
@view_config(route_name="bookmarks", renderer="bookmarks.jinja2") @view_config(route_name="bookmarks", renderer="bookmarks.jinja2")
@use_kwargs(PaginatedListingSchema) @use_kwargs(PaginatedListingSchema)
@use_kwargs( @use_kwargs(
{"post_type": String(load_from="type", validate=OneOf(("topic", "comment")))}
{
"post_type": String(
load_from="type", validate=OneOf(("topic", "comment")), missing="topic"
)
}
) )
def get_bookmarks( def get_bookmarks(
request: Request, request: Request,
@ -35,7 +39,7 @@ def get_bookmarks(
if post_type == "comment": if post_type == "comment":
post_cls = Comment post_cls = Comment
bookmark_cls = CommentBookmark bookmark_cls = CommentBookmark
else:
elif post_type == "topic":
post_cls = Topic post_cls = Topic
bookmark_cls = TopicBookmark bookmark_cls = TopicBookmark

Loading…
Cancel
Save