Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix BooleanColumn with choices set will always render as if True #301

Merged
merged 6 commits into from
Feb 9, 2016

Conversation

jieter
Copy link
Owner

@jieter jieter commented Jan 22, 2016

Refs #300, #290

This implements a fix for the failing tests as proposed by @onnokort. It's not really pretty though. What do you think @onnokort?

Also includes the test from #300.

TODO

  • Use Accessor.get_field() in BoundColumn.verbose_name.

@jieter
Copy link
Owner Author

jieter commented Jan 22, 2016

Aside from being ugly, this also doesn't work if the column uses a custom accessor :(

@jieter jieter force-pushed the onnokort-master branch 2 times, most recently from b110ec3 to bb07c80 Compare January 22, 2016 20:20
@jieter jieter changed the title Fix BooleanColun with choices set will always render as if True Fix BooleanColumn with choices set will always render as if True Jan 23, 2016
@jieter jieter force-pushed the onnokort-master branch 4 times, most recently from 293534d to d9f6f9d Compare January 23, 2016 11:16
@jieter
Copy link
Owner Author

jieter commented Jan 23, 2016

The current implementation should be more complete. Please tell me what you think @onnokort.

@onnokort
Copy link
Contributor

Code looks good. Let me try to backport these fixes and see whether my application does the right thing with them. Will get back to you on this. Oh, and thank you for this nice software!

@jieter
Copy link
Owner Author

jieter commented Jan 23, 2016

@onnokort thanks.

Just noticed that BoundColumn.verbose_name() also uses the model _meta API. I'll try to change that method to use the new get_field() method of Accessor too.

@jieter
Copy link
Owner Author

jieter commented Jan 23, 2016

This version looks even better.

@jieter jieter force-pushed the onnokort-master branch 2 times, most recently from b88939f to 5250177 Compare January 23, 2016 21:34
onnokort and others added 6 commits January 26, 2016 10:50
Adds test_boolean_field_choices_with_real_model_instances() to
tests/columns/test_booleancolumn.py.

After a wild-goose chase suspecting Django localization (which was
apparently not the problem), this is a test case that will fail for a
BooleanColumn representing a model.BooleanField with a
choices=... parameter set.

The reason that this test fails seems to be somewhere in the code path
that handles real model data. The test will pass when just using a pair of
mock-up dictionaries.

The test will also pass when removing the choices=... parameter from the
field = models.BooleanField(...) declaration.
- by using code previously used in BoundColumn.verbose_name
-  also make BoundColumn.verbose_name use the new implemenation
@jieter
Copy link
Owner Author

jieter commented Feb 4, 2016

@onnokort any news?

jieter added a commit that referenced this pull request Feb 9, 2016
Fix BooleanColumn with choices set will always render as if True
@jieter jieter merged commit 92059bb into master Feb 9, 2016
@jieter jieter deleted the onnokort-master branch February 9, 2016 13:40
jieter added a commit that referenced this pull request Feb 9, 2016
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants