Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting sort_field from model #42

Merged
merged 4 commits into from
Feb 15, 2021

Conversation

remiberthoz
Copy link
Contributor

It is now possible to define a sort_field value for notes by
setting a sort_field_number when creating the model.
When the sort_field argument is unused upon note creation, then
the field corresponding to the models sort_field_number will be
used. The default value is 1 (for first field).

The changes are compatible with previous versions.

remiberthoz added a commit to remiberthoz/anki-periodic-table-memory-pegs that referenced this pull request Nov 3, 2019
I'm using a custom fork of this package to ease notes sorting
inside Anki. A pull-request [1] with the modifications to genanki
has been submitted: in the future, I may update the submodule
dependancy to the original genanki repo [2].

[1] kerrickstaley/genanki#42
[2] https://github.com/kerrickstaley/genanki
remiberthoz added a commit to remiberthoz/anki-periodic-table-memory-pegs that referenced this pull request Nov 3, 2019
I'm using a custom fork of this package to ease notes sorting
inside Anki. A pull-request [1] with the modifications to genanki
has been submitted: in the future, I may update the submodule
dependancy to the original genanki repo [2].

[1] kerrickstaley/genanki#42
[2] https://github.com/kerrickstaley/genanki
README.md Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
genanki/model.py Outdated Show resolved Hide resolved
genanki/model.py Outdated Show resolved Hide resolved
genanki/model.py Outdated Show resolved Hide resolved
It is now possible to define a `sort_field` value for notes by
setting a `sort_field_number` when creating the model.
When the `sort_field` argument is unused upon note creation, then
the field corresponding to the models `sort_field_number` will be
used. The default value is `1` (for first field).

The changes are compatible with previous versions.
@remiberthoz
Copy link
Contributor Author

remiberthoz commented Feb 7, 2021

Sorry I don't know why it says I closed the PR... I forced-push on my master branch after rebasing on top of your master branch and resolving conflicts. I am normally two commits ahead.

@remiberthoz remiberthoz reopened this Feb 7, 2021
remiberthoz and others added 2 commits February 8, 2021 20:17
This prevents potentially breaking the API, because the order of the
arguments is part of the API.
@kerrickstaley
Copy link
Owner

@remiberthoz I pushed one quick change to your PR to avoid potentially breaking API compatibility, and it looks good to merge 😄 Will merge it momentarily once the CI tests pass.

One note is that we need to add tests that exercise this functionality. I can do that in the next few days or if you want to take it on, just comment here to let me know so we don't duplicate work.

@kerrickstaley kerrickstaley merged commit 7ff3c20 into kerrickstaley:master Feb 15, 2021
@remiberthoz
Copy link
Contributor Author

Hey, I will write the tests!

What behaviors would you like to test against? Of course, that the sorting index actually sorts when its used. Do you have edge-cases in mind?

@kerrickstaley
Copy link
Owner

@remiberthoz I think a simple "happy path" test case would be fine for this feature, just to make sure nobody accidentally breaks it in the future.

kerrickstaley pushed a commit that referenced this pull request Mar 27, 2021
Hi! Here is the test discussed in #42 - I hope it's fine 😄
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants