-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add bulk delete, bulk archive/unarchive, and bulk metadata edit buttons in books table page #3113
Open
jmarmstrong1207
wants to merge
20
commits into
janeczku:master
Choose a base branch
from
jmarmstrong1207:bulk-delete
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+611
−11
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
d0d9985
Add bulk delete button
jmarmstrong1207 d9a2a7a
Add bulk archive/unarchive buttons
jmarmstrong1207 ca9fc74
typo fix
jmarmstrong1207 34fec0e
Move buttons into table
jmarmstrong1207 4ed0633
Add bulk read/unread buttons; Fix buttons not working when moved into…
jmarmstrong1207 ecda717
Add bulk metadata edit button
jmarmstrong1207 ab3d4e4
Fix emptying metadata form after submit
jmarmstrong1207 9def910
switch title_sort to sort in api edit request
jmarmstrong1207 96fb2c1
Auto disable author/title sort input in metadata edit form
jmarmstrong1207 a335dd7
Make edit metadata pass all data in a single REST call. Modularize ed…
jmarmstrong1207 bee6a35
remove spacing
jmarmstrong1207 e31763d
Fix kobo sync status marking as archived even though state = false
jmarmstrong1207 2ae80d3
Fix book_read_status marking as read even though read_status is passe…
jmarmstrong1207 2afce66
Fix change_archived so state=none is a toggle. Fixes /togglearchived …
jmarmstrong1207 de3f883
Add change_archived_books() description
jmarmstrong1207 fe78222
Add shift-click to select multiple books at once
jmarmstrong1207 7e5d897
Merge branch 'master' into bulk-delete
jmarmstrong1207 31380f2
fix typo
jmarmstrong1207 338441f
fix author sort not updating when bulk editing
jmarmstrong1207 54d9d33
Revert "Add shift-click to select multiple books at once"
jmarmstrong1207 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,13 +51,15 @@ def remove_synced_book(book_id, all=False, session=None): | |
ub.session_commit(_session=session) | ||
|
||
|
||
# If state == none, it will toggle the archive state of the passed book_id. | ||
# state = true archives it, state = false unarchives it | ||
def change_archived_books(book_id, state=None, message=None): | ||
archived_book = ub.session.query(ub.ArchivedBook).filter(and_(ub.ArchivedBook.user_id == int(current_user.id), | ||
ub.ArchivedBook.book_id == book_id)).first() | ||
if not archived_book: | ||
if not archived_book and (state == True or state == None): | ||
archived_book = ub.ArchivedBook(user_id=current_user.id, book_id=book_id) | ||
|
||
archived_book.is_archived = state if state else not archived_book.is_archived | ||
archived_book.is_archived = state if state != None else not archived_book.is_archived | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without this, bulk unarchiving on already-unarchived books will actually archive them instead. Without this, this function is just a toggler if state is false. Same exact thing with edit_book_read_status is fixed in the commit below |
||
archived_book.last_modified = datetime.now(timezone.utc) # toDo. Check utc timestamp | ||
|
||
ub.session.merge(archived_book) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved the function to edit_book_param() in order to modularize it. This is so it can be used with the '/editselectedbooks/' calls. This essentially makes the change atomic from the client's perspective. Otherwise when bulk editing metadata, each metadata for each book needs an individual rest API call.