Add sort option to bookmark list (#522)

* Rename BookmarkFilters to BookmarkSearch

* Refactor queries to accept BookmarkSearch

* Sort query by data added and title

* Ensure pagination respects search parameters

* Ensure tag cloud respects search parameters

* Ensure user select respects search parameters

* Ensure return url respects search options

* Fix passing search options to user select

* Fix BookmarkSearch initialization

* Extract common search form logic

* Ensure partial update respects search options

* Add sort UI

* Use custom ICU collation when sorting with SQLite

* Support sort in API
This commit is contained in:
Sascha Ißbrücker
2023-09-01 22:48:21 +02:00
committed by GitHub
parent 0c50906056
commit 0975914a86
35 changed files with 1026 additions and 361 deletions

View File

@@ -29,7 +29,7 @@ class BookmarkFactoryMixin:
tags=None,
user: User = None,
url: str = '',
title: str = '',
title: str = None,
description: str = '',
notes: str = '',
website_title: str = '',
@@ -38,7 +38,7 @@ class BookmarkFactoryMixin:
favicon_file: str = '',
added: datetime = None,
):
if not title:
if title is None:
title = get_random_string(length=32)
if tags is None:
tags = []
@@ -81,6 +81,7 @@ class BookmarkFactoryMixin:
with_tags: bool = False,
user: User = None):
user = user or self.get_or_create_test_user()
bookmarks = []
if not prefix:
if archived:
@@ -105,7 +106,11 @@ class BookmarkFactoryMixin:
if with_tags:
tag_name = f'{tag_prefix} {i}{suffix}'
tags = [self.setup_tag(name=tag_name)]
self.setup_bookmark(url=url, title=title, is_archived=archived, shared=shared, tags=tags, user=user)
bookmark = self.setup_bookmark(url=url, title=title, is_archived=archived, shared=shared, tags=tags,
user=user)
bookmarks.append(bookmark)
return bookmarks
def get_numbered_bookmark(self, title: str):
return Bookmark.objects.get(title=title)
@@ -128,6 +133,9 @@ class BookmarkFactoryMixin:
user.profile.save()
return user
def get_random_string(self, length: int = 32):
return get_random_string(length=length)
class HtmlTestMixin:
def make_soup(self, html: str):