-
-
Notifications
You must be signed in to change notification settings - Fork 193
Respect 'using' in signals #200
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 8 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
af32447
Respect 'using' in signals
VaZark 913791c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 2d49fd5
Add test to respect using in kwargs
VaZark 932f461
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 098258a
Add failure test for invalid DB
VaZark 461da0f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 47c8806
WIP : postgres test is failing
VaZark 1eb7b97
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 69ccde8
remove unused import
VaZark 3c81ef8
clean up kwargs and update gitignore
VaZark d2841d4
setup test data once
VaZark 5a738ff
rename db replica
VaZark dbaf2d8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] e2e2ee4
reuse same db for replica
VaZark 5bd6362
Update tests
VaZark cc8ba71
Potential fix for pg test
VaZark 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,19 +17,23 @@ class Theme(models.Model): | |
@staticmethod | ||
def post_migrate_handler(**kwargs): | ||
del_cached_active_theme() | ||
Theme.get_active_theme() | ||
Theme.get_active_theme(**kwargs) | ||
|
||
@staticmethod | ||
def post_delete_handler(**kwargs): | ||
del_cached_active_theme() | ||
Theme.get_active_theme() | ||
Theme.get_active_theme(**kwargs) | ||
|
||
@staticmethod | ||
def post_save_handler(instance, **kwargs): | ||
|
||
del_cached_active_theme() | ||
if instance.active: | ||
Theme.objects.exclude(pk=instance.pk).update(active=False) | ||
Theme.get_active_theme() | ||
objs_manager = Theme.objects | ||
if "using" in kwargs: | ||
objs_manager = objs_manager.using(kwargs["using"]) | ||
objs_manager.exclude(pk=instance.pk).update(active=False) | ||
Theme.get_active_theme(**kwargs) | ||
|
||
@staticmethod | ||
def pre_save_handler(instance, **kwargs): | ||
|
@@ -42,8 +46,10 @@ def pre_save_handler(instance, **kwargs): | |
pass | ||
|
||
@staticmethod | ||
def get_active_theme(): | ||
def get_active_theme(*args, **kwargs): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay. I'll update all the references in the model to use |
||
objs_manager = Theme.objects | ||
if "using" in kwargs: | ||
objs_manager = objs_manager.using(kwargs["using"]) | ||
objs_active_qs = objs_manager.filter(active=True) | ||
objs_active_ls = list(objs_active_qs) | ||
objs_active_count = len(objs_active_ls) | ||
|
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
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.
This condition could be avoided by just doing:
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.
Since I'll be replacing
*args, **kwargs
could be replaced bydatabase="default", that can replace the
kwargs.get`. Will still be removing the if check.