* Added the ability to suspend/unsuspend cards.

* Added the ability to add/remove tags.
This commit is contained in:
David Snopek
2013-07-23 00:33:53 +01:00
parent 28ad457773
commit e582d8284b
2 changed files with 86 additions and 0 deletions

View File

@@ -412,6 +412,16 @@ class CollectionHandler(RestHandlerBase):
col.sched.answerCard(card, ease)
@noReturnValue
def suspend_cards(self, col, req):
card_ids = req.data['ids']
col.sched.suspendCards(card_ids)
@noReturnValue
def unsuspend_cards(self, col, req):
card_ids = req.data['ids']
col.sched.unsuspendCards(card_ids)
#
# GLOBAL / MISC
#
@@ -509,6 +519,20 @@ class NoteHandler(RestHandlerBase):
note = col.getNote(req.ids[1])
return self._serialize(note)
@noReturnValue
def add_tags(self, col, req):
note = col.getNote(req.ids[1])
for tag in req.data['tags']:
note.addTag(tag)
note.flush()
@noReturnValue
def remove_tags(self, col, req):
note = col.getNote(req.ids[1])
for tag in req.data['tags']:
note.delTag(tag)
note.flush()
class DeckHandler(RestHandlerBase):
"""Default handler group for 'deck' type."""
@@ -573,6 +597,22 @@ class CardHandler(RestHandlerBase):
card = col.getCard(req.ids[1])
return self._serialize(card, req.data)
def _forward_to_note(self, card_id, name):
card = col.getCard(card_id)
req_copy = req.copy()
req_copy.ids[1] = card.nid
return self.app.execute_handler('note', name, col, req)
@noReturnValue
def add_tags(self, col, req):
self._forward_to_note(req.ids[1], 'add_tags')
@noReturnValue
def remove_tags(self, col, req):
self._forward_to_note(req.ids[1], 'remove_tags')
# Our entry point
def make_app(global_conf, **local_conf):
# TODO: we should setup the default language from conf!