Move and delete chapters by hand in the chapter list
The merge cannot always tell where new chapters go. For example, a site can list an announcement before the chapters of an old book. You can now select chapters and move them, in their order, to after another chapter or to the start. You can also delete them with their revisions. A story keeps at least one chapter. The book is then rebuilt. A deleted chapter that the site still lists comes back with the next download. The Move… and Delete… buttons open a dialog that names the selected chapters before anything changes. A shift-click selects a range of chapters. The Select all checkbox moves into the first heading of the chapter list. On a phone, that heading shows with the text "Select all".
This commit is contained in:
@@ -250,6 +250,47 @@ def test_inclusion_changes_only_the_requested_story_and_queues_a_rebuild(state):
|
||||
assert len(queue.get_status()) == 1
|
||||
|
||||
|
||||
def test_move_chapters_keeps_their_order_and_queues_a_rebuild(state):
|
||||
store, queue = state
|
||||
sid, other = add_story(store), add_story(store, "other")
|
||||
ids = [store.add_chapter(sid, f"c{n}", str(n), "<p>x</p>", "h", "new", n) for n in range(5)]
|
||||
foreign = store.add_chapter(other, "foreign", "Other", "<p>x</p>", "h", "new", 0)
|
||||
|
||||
def titles():
|
||||
return [c["title"] for c in store.list_chapters(sid)]
|
||||
|
||||
# The selection order does not count, and a chapter of another story is ignored.
|
||||
assert o.move_chapters(sid, [ids[3], ids[1], foreign], ids[4])["mode"] == "rebuild"
|
||||
assert titles() == ["0", "2", "4", "1", "3"]
|
||||
o.move_chapters(sid, [ids[4], ids[3]], None)
|
||||
assert titles() == ["4", "3", "0", "2", "1"]
|
||||
assert len(queue.get_status()) == 1
|
||||
with pytest.raises(ValueError, match="Select"):
|
||||
o.move_chapters(sid, [foreign], None)
|
||||
with pytest.raises(ValueError, match="moves with them"):
|
||||
o.move_chapters(sid, [ids[0], ids[1]], ids[1])
|
||||
with pytest.raises(KeyError):
|
||||
o.move_chapters(sid, [ids[0]], foreign)
|
||||
|
||||
|
||||
def test_delete_chapters_removes_their_revisions_and_keeps_one_chapter(state):
|
||||
store, queue = state
|
||||
sid, other = add_story(store), add_story(store, "other")
|
||||
ids = [store.add_chapter(sid, f"c{n}", str(n), "<p>x</p>", "h", "new", n) for n in range(3)]
|
||||
store.add_revision(ids[1], "<p>y</p>", "h2", "recheck")
|
||||
foreign = store.add_chapter(other, "foreign", "Other", "<p>x</p>", "h", "new", 0)
|
||||
|
||||
assert o.delete_chapters(sid, [ids[1], foreign])["mode"] == "rebuild"
|
||||
assert [c["id"] for c in store.list_chapters(sid)] == [ids[0], ids[2]]
|
||||
assert store.list_revisions(ids[1]) == []
|
||||
assert store.get_chapter(foreign)
|
||||
with pytest.raises(ValueError, match="Select"):
|
||||
o.delete_chapters(sid, [foreign])
|
||||
with pytest.raises(ValueError, match="at least one chapter"):
|
||||
o.delete_chapters(sid, [ids[0], ids[2]])
|
||||
assert len(store.list_chapters(sid)) == 2
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"mode,chapters,fields,message",
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user