mirror of
https://github.com/sissbruecker/linkding.git
synced 2025-08-13 21:49:26 +02:00
Add configuration options for pagination (#835)
This commit is contained in:
@@ -955,3 +955,37 @@ class BookmarkListTemplateTest(TestCase, BookmarkFactoryMixin, HtmlTestMixin):
|
||||
self.assertInHTML(
|
||||
'<p class="empty-title h5">You have no bookmarks yet</p>', html
|
||||
)
|
||||
|
||||
def test_pagination_is_not_sticky_by_default(self):
|
||||
self.setup_bookmark()
|
||||
html = self.render_template()
|
||||
|
||||
self.assertIn('<div class="bookmark-pagination">', html)
|
||||
|
||||
def test_pagination_is_sticky_when_enabled_in_profile(self):
|
||||
self.setup_bookmark()
|
||||
profile = self.get_or_create_test_user().profile
|
||||
profile.sticky_pagination = True
|
||||
profile.save()
|
||||
html = self.render_template()
|
||||
|
||||
self.assertIn('<div class="bookmark-pagination sticky">', html)
|
||||
|
||||
def test_items_per_page_is_30_by_default(self):
|
||||
self.setup_numbered_bookmarks(50)
|
||||
html = self.render_template()
|
||||
|
||||
soup = self.make_soup(html)
|
||||
bookmarks = soup.select("li[ld-bookmark-item]")
|
||||
self.assertEqual(30, len(bookmarks))
|
||||
|
||||
def test_items_per_page_is_configurable(self):
|
||||
self.setup_numbered_bookmarks(50)
|
||||
profile = self.get_or_create_test_user().profile
|
||||
profile.items_per_page = 10
|
||||
profile.save()
|
||||
html = self.render_template()
|
||||
|
||||
soup = self.make_soup(html)
|
||||
bookmarks = soup.select("li[ld-bookmark-item]")
|
||||
self.assertEqual(10, len(bookmarks))
|
||||
|
@@ -43,6 +43,8 @@ class SettingsGeneralViewTestCase(TestCase, BookmarkFactoryMixin):
|
||||
"permanent_notes": False,
|
||||
"custom_css": "",
|
||||
"auto_tagging_rules": "",
|
||||
"items_per_page": "30",
|
||||
"sticky_pagination": False,
|
||||
}
|
||||
|
||||
return {**form_data, **overrides}
|
||||
@@ -111,6 +113,8 @@ class SettingsGeneralViewTestCase(TestCase, BookmarkFactoryMixin):
|
||||
"default_mark_unread": True,
|
||||
"custom_css": "body { background-color: #000; }",
|
||||
"auto_tagging_rules": "example.com tag",
|
||||
"items_per_page": "10",
|
||||
"sticky_pagination": True,
|
||||
}
|
||||
response = self.client.post(
|
||||
reverse("bookmarks:settings.update"), form_data, follow=True
|
||||
@@ -182,6 +186,13 @@ class SettingsGeneralViewTestCase(TestCase, BookmarkFactoryMixin):
|
||||
self.assertEqual(
|
||||
self.user.profile.auto_tagging_rules, form_data["auto_tagging_rules"]
|
||||
)
|
||||
self.assertEqual(
|
||||
self.user.profile.items_per_page, int(form_data["items_per_page"])
|
||||
)
|
||||
self.assertEqual(
|
||||
self.user.profile.sticky_pagination, form_data["sticky_pagination"]
|
||||
)
|
||||
|
||||
self.assertSuccessMessage(html, "Profile updated")
|
||||
|
||||
def test_update_profile_should_not_be_called_without_respective_form_action(self):
|
||||
|
Reference in New Issue
Block a user