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
Change census forms to post directly to census tables #19193
Conversation
@@ -123,8 +123,8 @@ $(document).ready(function () { | |||
}); | |||
|
|||
function checkShowCensusFollowUp() { | |||
if ($("#twenty-hour-how-much").val() === "some" || $("#twenty-hour-how-much").val() === "all" || $("#ten-hour-how-much").val() === "some" || | |||
$("#ten-hour-how-much").val() === "all") { | |||
if ($("#twenty-hour-how-much").val() === "SOME" || $("#twenty-hour-how-much").val() === "ALL" || $("#ten-hour-how-much").val() === "SOME" || |
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: break this long line up
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.
Agreed. From our styleguide:
Stick to an 80 character line length when possible, except for long URLs in comments or long regular expressions. Occasionally wiggling between 80 and 120 characters is OK in cases where it greatly improves the readability over a multiple line split.
@@ -63,14 +63,14 @@ class CensusForm extends Component { | |||
checkShowFollowUp() { | |||
const twentyHours = this.state.submission.twentyHours; | |||
this.setState({ | |||
showFollowUp: (twentyHours === 'some' || twentyHours === 'all') | |||
showFollowUp: (twentyHours === 'SOME' || twentyHours === 'ALL') | |||
}, this.checkShowPledge); | |||
} |
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.
Looks like for HoC signup we also show the follow up questions if tenHours === "ALL"
. Is that also the case for /yourschool?
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.
They actually have different checks. I'm already changing so much here that I didn't want to change this behavior also.
@@ -207,7 +221,7 @@ class CensusForm extends Component { | |||
const { errors } = this.state; | |||
if (!errors.email && !errors.topics && !errors.frequency && !errors.school && !errors.nces && !errors.role && !errors.hoc && !errors.afterSchool && !errors.tenHours && !errors.twentyHours && !errors.country) { | |||
$.ajax({ | |||
url: "/forms/Census2017", | |||
url: "/dashboardapi/v1/census/CensusYourSchool2017v4", |
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.
should this match line 267 in apps/src/sites/hourofcode.com/pages/public/index.js? What are the different versions of the form?
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.
The different form versions map to different models with different validation. They all write to the same table (census_submission) but with a different value for 'type'. This also allows us to map responses back to which version of the form was used.
@@ -207,7 +221,7 @@ class CensusForm extends Component { | |||
const { errors } = this.state; | |||
if (!errors.email && !errors.topics && !errors.frequency && !errors.school && !errors.nces && !errors.role && !errors.hoc && !errors.afterSchool && !errors.tenHours && !errors.twentyHours && !errors.country) { |
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.
Maybe tighten with something like:
if (Object.values(errors).every(error => !error)) {
// Submit...
@@ -300,7 +314,7 @@ class CensusForm extends Component { | |||
)} | |||
</div> | |||
<select | |||
name="hoc_s" | |||
name="how_many_do_hoc" |
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.
So we don't need the data type _s
appended to the name because that's an expectation of Pegasus forms, but not of your new table?
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.
Yes. I changed the naming in the forms to match the models and controller rather than making the models and controller match the existing form fields.
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.
The _s
suffixes are for SOLR to understand the data types when we index Pegasus forms. We don't use SOLR on the dashboard side, so don't need it.
@@ -544,7 +558,7 @@ class CensusForm extends Component { | |||
</div> | |||
<input | |||
type="text" | |||
name="name_s" | |||
name="submitter_name" |
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.
submitter_name
and pledged
are much clearer than the previous names - thanks for updating 🙂
assert_response 201, @response.body.to_s | ||
response = JSON.parse(@response.body) | ||
refute response['census_submission_id'].nil?, "census_submission_id expected in response: #{response}" | ||
end |
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.
Is it worth testing other variations of submissions beyond school? invalid email, etc?
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.
Or confirming schools with punctuation succeed?
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.
What do you mean by "schools with punctuation"?
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.
Looks good to me! A few questions, mostly for my own edification.
@@ -123,8 +123,8 @@ $(document).ready(function () { | |||
}); | |||
|
|||
function checkShowCensusFollowUp() { | |||
if ($("#twenty-hour-how-much").val() === "some" || $("#twenty-hour-how-much").val() === "all" || $("#ten-hour-how-much").val() === "some" || | |||
$("#ten-hour-how-much").val() === "all") { | |||
if ($("#twenty-hour-how-much").val() === "SOME" || $("#twenty-hour-how-much").val() === "ALL" || $("#ten-hour-how-much").val() === "SOME" || |
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.
Agreed. From our styleguide:
Stick to an 80 character line length when possible, except for long URLs in comments or long regular expressions. Occasionally wiggling between 80 and 120 characters is OK in cases where it greatly improves the readability over a multiple line split.
@@ -300,7 +314,7 @@ class CensusForm extends Component { | |||
)} | |||
</div> | |||
<select | |||
name="hoc_s" | |||
name="how_many_do_hoc" |
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.
The _s
suffixes are for SOLR to understand the data types when we index Pegasus forms. We don't use SOLR on the dashboard side, so don't need it.
].freeze | ||
|
||
# POST /dashboardapi/v1/census/<form_version> | ||
def new_submission |
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: Any reason we're not using the standard create
action?
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.
Just lack of awareness on my part. I'll make this change.
These changes will allow us to bypass the pegasus FORMS table and write directly to the census tables.
There are a few parts:
This should have no impact to the HoC signup form.