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

Specify mediaFile type=entityList for datasets in form manifest #1147

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/formats/openrosa.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const formManifestTemplate = template(200, `<?xml version="1.0" encoding="UTF-8"
<manifest xmlns="http://openrosa.org/xforms/xformsManifest">
{{#attachments}}
{{#hasSource}}
<mediaFile>
<mediaFile{{#isDataset}} type="entityList"{{/isDataset}}>
<filename>{{name}}</filename>
<hash>md5:{{openRosaHash}}</hash>
<downloadUrl>{{{domain}}}{{{basePath}}}/attachments/{{urlName}}</downloadUrl>
Expand All @@ -76,7 +76,8 @@ const formManifest = (data) => formManifestTemplate(mergeRight(data, {
attachments: data.attachments.map((attachment) =>
attachment.with({
hasSource: attachment.blobId || attachment.datasetId,
urlName: encodeURIComponent(attachment.name)
urlName: encodeURIComponent(attachment.name),
isDataset: attachment.datasetId != null
}))
}));

Expand Down
6 changes: 3 additions & 3 deletions test/integration/api/datasets.js
Original file line number Diff line number Diff line change
Expand Up @@ -1884,7 +1884,7 @@ describe('datasets and entities', () => {
const domain = config.get('default.env.domain');
manifest.should.equal(`<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns="http://openrosa.org/xforms/xformsManifest">
<mediaFile>
<mediaFile type="entityList">
<filename>goodone.csv</filename>
<hash>md5:${etag.replace(/"/g, '')}</hash>
<downloadUrl>${domain}/v1/projects/1/forms/withAttachments/attachments/goodone.csv</downloadUrl>
Expand Down Expand Up @@ -1968,7 +1968,7 @@ describe('datasets and entities', () => {
const domain = config.get('default.env.domain');
manifest.should.equal(`<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns="http://openrosa.org/xforms/xformsManifest">
<mediaFile>
<mediaFile type="entityList">
<filename>goodone.csv</filename>
<hash>md5:${etag.replace(/"/g, '')}</hash>
<downloadUrl>${domain}/v1/projects/1/forms/withAttachments/attachments/goodone.csv</downloadUrl>
Expand Down Expand Up @@ -2843,7 +2843,7 @@ describe('datasets and entities', () => {
const domain = config.get('default.env.domain');
text.should.be.eql(`<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns="http://openrosa.org/xforms/xformsManifest">
<mediaFile>
<mediaFile type="entityList">
<filename>people.csv</filename>
<hash>md5:${etag.replace(/"/g, '')}</hash>
<downloadUrl>${domain}/v1/projects/1/forms/withAttachments/attachments/people.csv</downloadUrl>
Expand Down