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

652: added Document (file) media type #668

Conversation

viniciuscb
Copy link

@viniciuscb viniciuscb commented Nov 2, 2019

Proposal for a Document media type.
Captura de tela_2019-11-03_15-04-36

Resolves #652

spec/requests/media/objects_spec.rb Outdated Show resolved Hide resolved
config/initializers/mime_types.rb Show resolved Hide resolved
app/models/report/standard_form_report.rb Outdated Show resolved Hide resolved
app/models/report/standard_form_report.rb Outdated Show resolved Hide resolved
app/models/media/document.rb Outdated Show resolved Hide resolved
app/models/media/document.rb Show resolved Hide resolved
app/models/media/document.rb Outdated Show resolved Hide resolved
app/models/media/document.rb Outdated Show resolved Hide resolved
app/models/media/document.rb Outdated Show resolved Hide resolved
app/models/media/document.rb Outdated Show resolved Hide resolved
@viniciuscb viniciuscb closed this Nov 2, 2019
@viniciuscb viniciuscb reopened this Nov 2, 2019
@viniciuscb viniciuscb closed this Nov 2, 2019
@viniciuscb viniciuscb reopened this Nov 2, 2019
@viniciuscb viniciuscb force-pushed the 652_add_file_question_type branch from 79b07ed to 6676ac7 Compare November 2, 2019 01:12
@viniciuscb viniciuscb force-pushed the 652_add_file_question_type branch from 6676ac7 to 121a17d Compare November 2, 2019 01:13
Signed-off-by: Vinicius Cubas Brand <[email protected]>
@viniciuscb viniciuscb force-pushed the 652_add_file_question_type branch from 121a17d to 3b7ca5f Compare November 2, 2019 01:14
@smoyte
Copy link
Contributor

smoyte commented Nov 8, 2019

Thanks for these PRs! Hoping to get to them next week. In the meantime, if you could resolve any merge conflicts (preferably with a rebase), that would be helpful!

Copy link
Contributor

@smoyte smoyte left a comment

Choose a reason for hiding this comment

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

Nice work! Very thorough! Thanks for taking the time to go through the whole codebase and cover all areas.

I have questions about ODK support. Let me know if that's been tested. If it has, wow, surprise for me! If it hasn't, I'm pretty sure it's not supported, so let's take it out and add a spec to ensure document questions aren't rendered for ODK. See the form_rendering_spec.rb file.

@@ -127,6 +127,7 @@ def media_type
when "image", "annotated_image", "sketch", "signature" then "image/*"
when "audio" then "audio/*"
when "video" then "video/*"
when "document" then "document/*"
Copy link
Contributor

Choose a reason for hiding this comment

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

Has this been tested in ODK Collect? What does it do? I know that image, audio, and video have specific meanings in Collect but I haven't heard of "document" in that context. If it's not supported by ODK then we should not be rendering this question type when rendering for Collect, and this deliberate omission should be tested in the form_rendering_spec.rb

Copy link
Author

Choose a reason for hiding this comment

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

Hi @smoyth. Yes, we've tested in ODK collect and also in Nemo web interface. I've tested by uploading a document (pdf, odt, doc) in the collect, the answer was saved and after I could download/preview that document in the answer screen. This also worked in the web interface.

application/vnd.oasis.opendocument.presentation
application/x-ole-storage].freeze
ODK_MEDIA_EXTS = {audio: %w[mp3 ogg wav flac], video: %w[mp4], image: %w[png jpg jpeg],
document: %w[pdf xls xlsx ods doc docx odt rtf ppt pptx odp csv txt]}.freeze
Copy link
Contributor

Choose a reason for hiding this comment

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

If ODK doesn't support the document type then all of this can be removed, yes?

"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
# sometimes mimemagic returns x-ole-storage for msoffice files: https://github.com/minad/mimemagic/issues/50
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the comment!

@@ -75,6 +75,10 @@ class QuestionType
name: "video",
odk_name: "binary",
properties: %w[multimedia]
}, {
name: "document",
odk_name: "binary",
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe don't need this?

# upload valid document
drop_in_dropzone(document, 2)
expect_preview(document_node)

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice specs!

@@ -0,0 +1,2 @@
This is a document.,
"Answer to the Ultimate Question of Life, the Universe, and Everything:",42
Copy link
Contributor

Choose a reason for hiding this comment

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

😆

</text>
<text id="*itemcode4*:hint">
<value>Question Hint 4</value>
</text>
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious if this works too. In the docs, I only see support for image, audio, and photo media prompts:

https://docs.opendatakit.org/form-styling/

@@ -4,7 +4,7 @@ module Odk
class QuestionDecorator < ApplicationDecorator
delegate_all

URI_DIRS_BY_TYPE = {video: "video", audio: "audio", image: "images"}.freeze
URI_DIRS_BY_TYPE = {video: "video", audio: "audio", image: "images", document: "document"}.freeze
Copy link
Contributor

Choose a reason for hiding this comment

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

If ODK document media prompts aren't supported then this should be removed too.

@cooperka cooperka force-pushed the develop branch 4 times, most recently from cfd1f24 to cf84400 Compare June 30, 2020 00:11
@smoyte smoyte closed this Jul 20, 2020
@cooperka cooperka reopened this Jul 22, 2020
@cooperka cooperka changed the base branch from develop to master July 22, 2020 21:36
@cooperka cooperka changed the base branch from master to main July 31, 2020 18:53
@cooperka cooperka force-pushed the main branch 5 times, most recently from 74cb6eb to 62b3d8d Compare August 27, 2020 00:29
@smoyte
Copy link
Contributor

smoyte commented Jan 21, 2021

Closing for now due to age. Can be opened again later.

@smoyte smoyte closed this Jan 21, 2021
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.

Add "file" question type - for documents (pdf, doc, odt, ods, xls...)
4 participants