-
Notifications
You must be signed in to change notification settings - Fork 649
Use Box.objects.get_or_create #1315
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
Conversation
Looking at this again I think this could even be changed to |
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.
You're right, changing the code to use update_or_create()
would be better.
99caa5d
to
3f9593a
Compare
I've updated the PR to use |
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 looks like a good cleanup, thanks! I only have a comment about using trailing commas after the last item of the dict.
blogs/parser.py
Outdated
label='supernav-python-blog', | ||
defaults={ | ||
'content': rendered_box, | ||
'content_markup_type': 'html' |
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.
Nit: Please add a trailing comma.
downloads/models.py
Outdated
label='supernav-python-downloads', | ||
defaults={ | ||
'content': content, | ||
'content_markup_type': 'html' |
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.
Nit: Please add a trailing comma.
downloads/models.py
Outdated
label='download-sources', | ||
defaults={ | ||
'content': source_content, | ||
'content_markup_type': 'html' |
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.
Nit: Please add a trailing comma.
downloads/models.py
Outdated
label='homepage-downloads', | ||
defaults={ | ||
'content': content, | ||
'content_markup_type': 'html' |
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.
Nit: Please add a trailing comma.
successstories/models.py
Outdated
label='supernav-python-success-stories', | ||
defaults={ | ||
'content': content, | ||
'content_markup_type': 'html' |
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.
Nit: Please add a trailing comma.
This makes it possible to create a release without installing the Box fixtures
Remove unnecessary box creation from test cases
3f9593a
to
fbd89f2
Compare
I've added the trailing commas. On a related note: It might be interesting to run black on this codebase at some point. That would fix a lot of existing code style inconsistencies. |
Thanks!
Sorry, I dislike some of the style choices of black :) Also, we don't accept cosmetic-only patches in CPython, so I'd like to follow that rule in python.org as well. |
This makes it possible to create a release without installing the Box fixtures.
This should be perfectly safe as the box content is set immediately after getting/creating the box.