fix fail-on-template-vars errors#2899
Open
dantagg wants to merge 6 commits into
Open
Conversation
…template logic for dc_base_theme
…NICAL_URL to settings
"templates.E002: string_if_invalid in TEMPLATES OPTIONS must be a string but got: {value} ({type})"
Clashes with pytest-django issue DemocracyClub#750, see
pytest-dev/pytest-django#750
GeoWill
requested changes
Nov 13, 2020
GeoWill
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for this @dantagg.
It essentially looks good, but there are a couple of changes before merging. If you don't have time to do them I'm happy to, just let me know 🙂 .
- First off, until I understand it better I'd drop 33e3ab. We're not running checks regularly with
--fail-on-templateso I don't want to risk hiding errors that we'd want to surface. If this is a problem with how pytest-django overwritesstring_if_invalidthen I'd rather raise an issue there. Saying that I haven't wrapped my head around it properly so happy to hear otherwise. - I think the
CANONICAL_URLvariable should point to our domain root. Though as I said in my comment perhaps we should bin the tag entirely.
Style and GNit picks:
- Squash f1fd3d into eb1515
- Make sure Travis passes - this will be black and pyflakes issues. You can run
black .andpytest --flakeslocally. - Reformat commits so that the first line is 50 characters and the body wraps at 72.
Thanks again, and let me know if any of that doesn't make sense, or how to do it.
| if len(sys.argv) > 1 and sys.argv[1] in ["test", "harvest"]: | ||
| from .testing import * # noqa | ||
|
|
||
| CANONICAL_URL= '' No newline at end of file |
Collaborator
There was a problem hiding this comment.
I think this should line should be:
CANONICAL_URL= 'https://wheredoivote.co.uk'However this is all so that we can see how well our links are shared on fb, which I'm not sure we'll ever do. Anyway for now at least having the right url seems sensible.
Author
|
Hi Will,
Happy to make the changes as you suggest. I'll get them done some time over
the next week and send another pull request.
Have a nice weekend
Dan
…On Fri, 13 Nov 2020 at 16:58, Will Roper ***@***.***> wrote:
***@***.**** requested changes on this pull request.
Thanks for this @dantagg <https://github.com/dantagg>.
It essentially looks good, but there are a couple of changes before
merging. If you don't have time to do them I'm happy to, just let me know
🙂 .
- First off, until I understand it better I'd drop 33e3ab. We're not
running checks regularly with --fail-on-template so I don't want to
risk hiding errors that we'd want to surface. If this is a problem with how
pytest-django overwrites string_if_invalid then I'd rather raise an
issue there. Saying that I haven't wrapped my head around it properly so
happy to hear otherwise.
- I think the CANONICAL_URL variable should point to our domain root.
Though as I said in my comment perhaps we should bin the tag entirely.
Style and GNit picks:
- Squash f1fd3d into eb1515
- Make sure Travis passes - this will be black and pyflakes issues.
You can run black . and pytest --flakes locally.
- Reformat commits so that the first line is 50 characters and the
body wraps at 72.
Thanks again, and let me know if any of that doesn't make sense, or how to
do it.
------------------------------
In polling_stations/settings/base.py
<#2899 (comment)>
:
> @@ -301,3 +302,5 @@
# importing test settings file if necessary (TODO chould be done better)
if len(sys.argv) > 1 and sys.argv[1] in ["test", "harvest"]:
from .testing import * # noqa
+
+CANONICAL_URL= ''
I think this should line should be:
CANONICAL_URL= 'https://wheredoivote.co.uk'
However this is all so that we can see how well our links are shared on
fb, which I'm not sure we'll ever do. Anyway for now at least having the
right url seems sensible.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2899 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADICUA46NNQSZD74MN2FZLSPVQU7ANCNFSM4TEB3SIA>
.
--
Wildman and Herring Limited, Registered Office: 4 Beau Street, Bath, United
Kingdom, BA1 1QY, Company no: 05766374
|
Collaborator
Feel free to force push to this one 🙂 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes nearly all errors from running
pytest --fail-on-template-varsas requested in issue #2802.string_if_invalid
when setting
pytest --fail-on-template-vars, pytest-django overwrites the template optionstring_if_invalidto an exception. This causes a lot of errors of the form'string_if_invalid' in TEMPLATES OPTIONS must be a string but got: ...33e3abf removes this error by not running the system checktemplates.E002when testing.required_css_class
The
dc_base_themerepository'sfield.htmltemplate expects the form to have arequired_css_classproperty. eb15152 and 6a98de9 add those properties to the relevant forms. It may be that a better solution is to remove the expectation of that property from the template.CANONICAL_URL
The
base_full.htmltemplate expectsCANONICAL_URLin its context. 0af9439 creates a context_processor to addCANONICAL_URLto context. 9330d48 adds this context processor to the list of context processors and adds the setting variableCANONICAL_URLtobase_settings.py. This will need to be overridden in production.Undefined template variable 'media'
The outstanding error is
Failed: Undefined template variable 'media' in '.../site-packages/pipeline/templates/pipeline/css.html'.