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">
<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>
</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>
</li>
</menu>
@ -35,7 +35,7 @@
{% endfor %}
</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">
{% if posts.has_prev_page %}
<a class="page-item btn" id="prev-page"
@ -52,7 +52,13 @@
{% endif %}
{% else %}
<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>
{% 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")
@use_kwargs(PaginatedListingSchema)
@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(
request: Request,
@ -35,7 +39,7 @@ def get_bookmarks(
if post_type == "comment":
post_cls = Comment
bookmark_cls = CommentBookmark
else:
elif post_type == "topic":
post_cls = Topic
bookmark_cls = TopicBookmark

Loading…
Cancel
Save