Skip to content

Commit

Permalink
Specify mediaFile type for entity lists in manifest (#1147)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktuite authored May 23, 2024
1 parent fecb067 commit e1c74de
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
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

0 comments on commit e1c74de

Please sign in to comment.