Merge pull request #23 from techdavid/add-changedeck
Add changeDeck function
This commit is contained in:
commit
c09c171dcd
@ -507,6 +507,23 @@ class AnkiBridge:
|
||||
return []
|
||||
|
||||
|
||||
def changeDeck(self, cards, deck):
|
||||
self.startEditing()
|
||||
|
||||
did = self.window().col.decks.id(deck)
|
||||
mod = anki.utils.intTime()
|
||||
usn = self.window().col.usn()
|
||||
|
||||
# normal cards
|
||||
scids = anki.utils.ids2str(cards)
|
||||
# remove any cards from filtered deck first
|
||||
self.window().col.sched.remFromDyn(cards)
|
||||
|
||||
# then move into new deck
|
||||
self.window().col.db.execute('update cards set usn=?, mod=?, did=? where id in ' + scids, usn, mod, did)
|
||||
self.stopEditing()
|
||||
|
||||
|
||||
def cardsToNotes(self, cards):
|
||||
return self.window().col.db.list('select distinct nid from cards where id in ' + anki.utils.ids2str(cards))
|
||||
|
||||
@ -785,6 +802,11 @@ class AnkiConnect:
|
||||
return self.anki.findCards(query)
|
||||
|
||||
|
||||
@webApi
|
||||
def changeDeck(self, cards, deck):
|
||||
return self.anki.changeDeck(cards, deck)
|
||||
|
||||
|
||||
@webApi
|
||||
def cardsToNotes(self, cards):
|
||||
return self.anki.cardsToNotes(cards)
|
||||
|
20
README.md
20
README.md
@ -490,6 +490,26 @@ Below is a list of currently supported actions. Requests with invalid actions or
|
||||
]
|
||||
```
|
||||
|
||||
* **changeDeck**
|
||||
|
||||
Moves cards with the given IDs to a different deck, creating the deck if it doesn't exist yet.
|
||||
|
||||
*Sample request*:
|
||||
```
|
||||
{
|
||||
"action": "changeDeck",
|
||||
"params": {
|
||||
"cards": [1502098034045, 1502098034048, 1502298033753],
|
||||
"deck": "Japanese::JLPT N3"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
*Sample response*:
|
||||
```
|
||||
null
|
||||
```
|
||||
|
||||
* **cardsToNotes**
|
||||
|
||||
Returns an (unordered) array of note IDs for the given card IDs. For cards with the same note, the ID is only
|
||||
|
Loading…
Reference in New Issue
Block a user