-
Notifications
You must be signed in to change notification settings - Fork 4
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
Existing plant lines upload #781
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
424e8c9
Fix js error handling of failed uploads
kammerer 6d26c2d
Allow to upload existing plant lines in PP submission
kammerer e2ced0f
Allow existing PLs with no species information
kammerer 68dc259
Allow to freely override PLs via file upload
kammerer f014dbe
Fix error message formatting in PL upload
kammerer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
$ -> | ||
new PlantPopulationSubmission('.edit-population-submission').init() | ||
window.pp = new PlantPopulationSubmission('.edit-population-submission') | ||
window.pp.init() | ||
new PlantTrialSubmission('.edit-trial-submission').init() | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,30 @@ | ||
class SubmissionPlantLinesUploadDecorator < SubmissionUploadDecorator | ||
def as_json(*) | ||
super.merge(uploaded_plant_lines: uploaded_plant_lines) | ||
super.merge(uploaded_existing_plant_lines: uploaded_existing_plant_lines, | ||
uploaded_new_plant_lines: uploaded_new_plant_lines) | ||
end | ||
|
||
private | ||
|
||
def uploaded_plant_lines | ||
submission.content.uploaded_plant_lines | ||
submission.content.uploaded_plant_lines || [] | ||
end | ||
|
||
def new_plant_lines | ||
submission.content.new_plant_lines || [] | ||
end | ||
|
||
def uploaded_existing_plant_lines | ||
PlantLine. | ||
visible(submission.user_id). | ||
where(plant_line_name: uploaded_plant_lines). | ||
pluck(:id, :plant_line_name). | ||
map { |id, plant_line_name| { id: id, plant_line_name: plant_line_name } } | ||
end | ||
|
||
def uploaded_new_plant_lines | ||
new_plant_lines.select do |plant_line_attrs| | ||
uploaded_plant_lines.include?(plant_line_attrs.fetch("plant_line_name")) | ||
end | ||
end | ||
end |
This file contains 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
Oops, something went wrong.
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.
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.
This works - I was able to see a 500 error when I uploaded a wrong file. What is wrong, however, that I got that 500 in the first place. I tried to upload a completely wrong file and I caught BIP trying to select on nil:
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.
Do you remember what kind of file you uploaded? I only managed to get this 500 response using a badly encoded file, otherwise I get regular error message such as "File content type is invalid".
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 did it with two files, one was even a CSV, only a completely different one (than expected). I also remember I selected nothing on the 2nd step. The 3rd step was also empty when I uploaded the file.
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.
OK, fixed.