This commit is contained in:
Alex Yatskov 2018-03-31 14:40:01 -07:00
parent d3627e3060
commit 0efa203095

View File

@ -117,7 +117,6 @@ def verifyStringList(strings):
return True
#
# AjaxRequest
#
@ -338,6 +337,7 @@ class AnkiNoteParams:
type(self.tags) == list and verifyStringList(self.tags)
)
def __str__(self):
return 'DeckName: ' + self.deckName + '. ModelName: ' + self.modelName + '. Fields: ' + str(self.fields) + '. Tags: ' + str(self.tags) + '.'
@ -437,6 +437,7 @@ class AnkiBridge:
elif duplicateOrEmpty == False:
return note
def updateNoteFields(self, params):
collection = self.collection()
if collection is None:
@ -450,6 +451,7 @@ class AnkiBridge:
note[name] = value
note.flush()
def addTags(self, notes, tags, add=True):
self.startEditing()
self.collection().tags.bulkAdd(notes, tags, add)
@ -479,6 +481,7 @@ class AnkiBridge:
return False
def isSuspended(self, card):
card = self.collection().getCard(card)
if card.queue == -1:
@ -486,6 +489,7 @@ class AnkiBridge:
else:
return False
def areSuspended(self, cards):
suspended = []
for card in cards:
@ -725,6 +729,7 @@ class AnkiBridge:
else:
return []
def cardsInfo(self,cards):
result = []
for cid in cards:
@ -762,6 +767,7 @@ class AnkiBridge:
return result
def notesInfo(self,notes):
result = []
for nid in notes:
@ -813,6 +819,7 @@ class AnkiBridge:
return deckId
def changeDeck(self, cards, deck):
self.startEditing()
@ -906,6 +913,7 @@ class AnkiBridge:
else:
return False
def guiShowQuestion(self):
if self.guiReviewActive():
self.reviewer()._showQuestion()
@ -959,6 +967,7 @@ class AnkiBridge:
else:
return False
def guiExitAnki(self):
timer = QTimer()
def exitAnki():
@ -967,9 +976,11 @@ class AnkiBridge:
timer.timeout.connect(exitAnki)
timer.start(1000) # 1s should be enough to allow the response to be sent.
def sync(self):
self.window().onSync()
#
# AnkiConnect
#
@ -1134,10 +1145,12 @@ class AnkiConnect:
return results
@webApi()
def updateNoteFields(self, note):
return self.anki.updateNoteFields(note)
@webApi()
def canAddNotes(self, notes):
results = []
@ -1230,10 +1243,12 @@ class AnkiConnect:
def getDecks(self, cards):
return self.anki.getDecks(cards)
@webApi()
def createDeck(self, deck):
return self.anki.createDeck(deck)
@webApi()
def changeDeck(self, cards, deck):
return self.anki.changeDeck(cards, deck)
@ -1303,14 +1318,17 @@ class AnkiConnect:
def guiExitAnki(self):
return self.anki.guiExitAnki()
@webApi()
def cardsInfo(self, cards):
return self.anki.cardsInfo(cards)
@webApi()
def notesInfo(self, notes):
return self.anki.notesInfo(notes)
@webApi()
def sync(self):
return self.anki.sync()