Skip to content

Commit

Permalink
Fix inconsistent tag order in bookmarks (sissbruecker#819)
Browse files Browse the repository at this point in the history
  • Loading branch information
sissbruecker authored Sep 10, 2024
1 parent b304863 commit cb0301f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bookmarks/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ def resolved_description(self):

@property
def tag_names(self):
return [tag.name for tag in self.tags.all()]
names = [tag.name for tag in self.tags.all()]
return sorted(names)

def __str__(self):
return self.resolved_title + " (" + self.url[:30] + "...)"
Expand Down
16 changes: 16 additions & 0 deletions bookmarks/tests/test_bookmarks_list_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,22 @@ def test_bookmark_description_max_lines(self):
style = bookmark_list["style"]
self.assertIn("--ld-bookmark-description-max-lines:3;", style)

def test_bookmark_tag_ordering(self):
bookmark = self.setup_bookmark()
tag3 = self.setup_tag(name="tag3")
tag1 = self.setup_tag(name="tag1")
tag2 = self.setup_tag(name="tag2")
bookmark.tags.add(tag3, tag1, tag2)

html = self.render_template()
soup = self.make_soup(html)
tags = soup.select_one(".tags")
tag_links = tags.find_all("a")
self.assertEqual(len(tag_links), 3)
self.assertEqual(tag_links[0].text, "#tag1")
self.assertEqual(tag_links[1].text, "#tag2")
self.assertEqual(tag_links[2].text, "#tag3")

def test_should_render_web_archive_link_with_absolute_date_setting(self):
bookmark = self.setup_date_format_test(
UserProfile.BOOKMARK_DATE_DISPLAY_ABSOLUTE,
Expand Down

0 comments on commit cb0301f

Please sign in to comment.