Skip to content
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

[#112216471] Shove the logic for boolean_list questions into Content Loader #248

Merged
merged 7 commits into from
Mar 8, 2016

Conversation

pcraig3
Copy link
Contributor

@pcraig3 pcraig3 commented Mar 4, 2016

After a few false starts on how to handle the boolean_list_question type, this seems to me to be the neatest way to get all the non-reusable code into the ContentLoader.

Two main things: (1) adding brief questions to the section data and (2) getting the right error messages.

  • Boolean list questions need, at some point, to receive a list of questions typed by buyers into their brief. Adding .inject_brief_questions_into_boolean_list_question() methods to both the ContentSection and the ContentQuestion is a fairly straightforward way to do this.
  • Calling .get_error_messages() on a ContentQuestionSummary returns the right error messages for boolean lists
    • if self.id key is returned by API's validation messages
    • if self.type == 'boolean_list'
    • if a boolean_list_questions key exists

Logic in the supplier app is wayyy simpler.

Wrote the tests. Should be good to go.

@pcraig3 pcraig3 changed the title [What do we think?] [What do we think?] boolean_list_questions in Content Loader Mar 4, 2016
@TheDoubleK
Copy link
Contributor

You're seriously asking us to look at this?
screen shot 2016-03-04 at 16 56 59

@pcraig3
Copy link
Contributor Author

pcraig3 commented Mar 4, 2016

Wouldn't dream of it, Kev.

@pcraig3 pcraig3 force-pushed the pc_supplier_reply_responses branch from a4a9f24 to 8aa5355 Compare March 4, 2016 17:16
Adds the capability to inject brief data into `boolean_list`
questions, and then, afterwards, to return the correct error
messages for each individual `boolean_list` question by asking
for error messages from `ContentQuestionSummary` objects rather
than `ContentQuestions` themselves.

There's kind of a depenency in that `boolean_list` question
error messages expect brief data to have been added to the
question before the errors are generated, but nothing that would
result in a fatal error.
@pcraig3 pcraig3 force-pushed the pc_supplier_reply_responses branch from 8aa5355 to ec4aec4 Compare March 7, 2016 10:22
pcraig3 added 5 commits March 7, 2016 10:44
Order of messages is important for the new error message stuff.
Seems harmless to use ordered dictionaries everywhere.
Also updated CHANGELOG detailing breaking change.
@pcraig3 pcraig3 force-pushed the pc_supplier_reply_responses branch from ec4aec4 to b462162 Compare March 7, 2016 10:48
@pcraig3 pcraig3 changed the title [What do we think?] boolean_list_questions in Content Loader [#112216471] Shove the logic for boolean_list questions into Content Loader Mar 7, 2016
@pcraig3
Copy link
Contributor Author

pcraig3 commented Mar 7, 2016

screen shot 2016-03-07 at 10 58 21

@@ -319,6 +318,10 @@ def get_question_by_slug(self, question_slug):
if question.get('slug') == question_slug:
return question

def inject_brief_questions_into_boolean_list_question(self, brief):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this name should be more generic - we could in theory have boolean lists that aren't to do with briefs?
e.g. inject_list_of_questions_into_boolean_list or similar. (In which case the parameter would be something more generic than brief too).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I tend to agree with your final comment. We only need these for briefs, so with our really specific method naming it's obvious what they're doing.

@TheDoubleK
Copy link
Contributor

Nice work on the test coverage.

I'm not sure about the naming stuff - maybe just stick with briefs for now as it makes it clear what the methods expect and what it's all used for, and it can be made generic if it's ever re-used for something else?

Gets a 👍 from me, but would be nice to have someone else look it over too I reckon.

pcraig3 added a commit that referenced this pull request Mar 8, 2016
[#112216471] Shove the logic for `boolean_list` questions into Content Loader
@pcraig3 pcraig3 merged commit c833e0d into master Mar 8, 2016
@pcraig3 pcraig3 deleted the pc_supplier_reply_responses branch March 8, 2016 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants