-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #135 from aplaice/disambiguate_cloned_deckconf
Avoid duplicating crowdanki_uuid when cloning deck config
- Loading branch information
Showing
2 changed files
with
21 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Note that this only works for Anki ≤ 2.1.45, or when using the old | ||
# deck options popup with Anki 2.1.46+. Anki 2.1.46+ has a new | ||
# JavaScript-based options popup (with no hooks), by default. | ||
|
||
from .constants import UUID_FIELD_NAME | ||
|
||
def disambiguate_crowdanki_uuid(deck_conf, deck, | ||
config, new_name, | ||
new_conf_id): | ||
new_deck_conf = deck_conf.mw.col.decks.get_config(new_conf_id) | ||
if (new_deck_conf and (UUID_FIELD_NAME in new_deck_conf)): | ||
# Delete rather than generating anew, (with uuid1()) to avoid code duplication. | ||
del new_deck_conf[UUID_FIELD_NAME] | ||
deck_conf.mw.col.decks.update_config(new_deck_conf) |