-
Notifications
You must be signed in to change notification settings - Fork 34
Add WorkCluster class for merging works (dedupe, suggestions, or merge from admin) #307
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5c8d21e
Add WorkCluster to admin
jilljenn bb78f2a
Add migration
jilljenn 4b44e96
Allow call to merge from WorkCluster admin
jilljenn 2ab8167
Add test for merge action
jilljenn 02dd3ba
Add all_objects manager and format_html
jilljenn cc04bd4
Merge branch 'master' into jj/add-workcluster
jilljenn 2a39179
Add migration file for manager
jilljenn 130915a
Butchering migrations
jilljenn 9774f09
Make a better test for merging, in order to reduce the number of queries
jilljenn 650371a
Cover all merge functions with tests, reduce the number of queries wh…
jilljenn a7e292b
Merge branch 'master' into jj/add-workcluster
jilljenn 0a8a706
Resolve multiplication of migration leaves
jilljenn d000a3d
Cut line
jilljenn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't it make sense for the default
Work
queryset to exclude those so-called phantom works, with explicit overrides (via aWork.all_objects
or some such) when we really want to see them appear -- which would probably be only when viewing aWork
and redirecting to its canonical version?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but I can't make it. Can you? I mean, how to add extra elements when the whole source is filtered?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just define two managers
Work
, see https://docs.djangoproject.com/en/1.11/topics/db/managers/#modifying-a-manager-s-initial-querysetNB: Since we use a custom QuerySet for Works, you should use
from_queryset
; something like the following:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
J'ai eu des soucis avec les ManyToMany.
Source : Django
On fait toujours ça ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah oui zut j'avais oublié ce truc désolé :-/ That's the right fix.
There was a problem hiding this comment. 9E81
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this
get_queryset
function in the admin can be removed now?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually the behavior is inconsistent with the doc since Django seems to be using the default manager for related object accesses instead of the base manager... I'm investigating.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this is indeed only used for one-to-one fields due to historical reasons, which is unfortunate. I think I'd prefer using
WorkCluster.objects.get(id=10).works(manager='all_objects').all()
instead, sinceWorkCluster
is "special" in the sense that it essentially the only class that should see the removedWorks
, we want them to appear as non-existent for other objects. Not 100% sure though, I think the manual solution works for now -- I'd appreciate a comment there explaining that we use manual filtering because ManyToManyField doesn't honor thedefault_manager
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done:
# Equivalent to default_manager_name = 'all_objects', because first in the list
.