-
Notifications
You must be signed in to change notification settings - Fork 479
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
Set status directly instead of in form data #44874
Changes from 7 commits
21a070a
fd9629d
5cf12c3
d10ac2e
4abafd6
3de50d7
18e07fd
e2f09a3
d8d14db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,12 +4,17 @@ def new_form | |
end | ||
|
||
def create | ||
form_data_hash = params.try(:[], :form_data) || {} | ||
form_data_json = form_data_hash.to_unsafe_h.to_json.strip_utf8mb4 | ||
|
||
form = new_form | ||
|
||
form_data_hash = params.try(:[], :form_data) | ||
form_data_json = form_data_hash ? form_data_hash.to_unsafe_h.to_json.strip_utf8mb4 : {}.to_json | ||
form.form_data_hash = JSON.parse(form_data_json) | ||
|
||
status = params.try(:[], :status) | ||
if status | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. optional / for next time: I am not sure why the existing code is using params.try here, because params should always be defined in a controller method. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh, good to know! I'll make a note of it and include in a future PR. Thanks. |
||
@application.status = status | ||
end | ||
|
||
# Check for idempotence | ||
existing_form = form.check_idempotency | ||
return render json: {id: existing_form.id}, status: :ok if existing_form | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ def new | |
if @application | ||
return render :submitted if @application.status != 'incomplete' | ||
@application_id = @application.try(:id) | ||
@saved_status = @application.try(:status) | ||
@form_data = @application.try(:form_data) | ||
end | ||
|
||
|
@@ -36,6 +37,7 @@ def new | |
userId: current_user.id, | ||
schoolId: current_user.school_info&.school&.id, | ||
applicationId: @application_id, | ||
savedStatus: @saved_status, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will be needed once an RP can reopen an application |
||
savedFormData: @form_data | ||
}.to_json | ||
} | ||
|
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.
I'm leaving this as a to-do because soon, we'll need to have a 'reopened' status if an RP reopens an application. We should check savedStatus for both of these cases.