Commit 959d83b7 authored by Anton's avatar Anton

Add override author option to archives

parent 22028ac0
......@@ -7,7 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
No changes.
### Added
- Override author option for archives
### Fixed
- Import timeline/grid properly creates copies
## [1.2.3] - 2019-03-03
......
......@@ -36,7 +36,11 @@ const setupArchives = function (api, mapService, annotationService) {
api.app.post('/archives/maps/upload', async function (req, res) {
upload.single('file')(req, res, async () => {
const results = await readArchive(req.file.path)
const copy = req.body.title || false
const
copy = req.body.title || false,
overrideAuthor = req.body.overrideAuthor === 'true' ? true : false
// skipAcl = req.body.skipAcl === 'true' ? true : false
let hasDuplicates = false
if (results.maps && !copy) {
for (let map of results.maps) {
......@@ -63,15 +67,16 @@ const setupArchives = function (api, mapService, annotationService) {
const mappings = {}
if (results.maps) {
for (let map of results.maps) {
let oldId = map.uuid
let oldId = map.id
for (let k of Object.keys(map)) {
if (k[0] === '_') map[k] = undefined
}
if (copy) {
map.title = req.body.title
map.uuid = undefined
map.id = null
map.uuid = null
}
if (!map.author) {
if (!map.author || overrideAuthor) {
map.author = {
id: req.user.uuid,
name: req.user.profile.name
......@@ -82,7 +87,7 @@ const setupArchives = function (api, mapService, annotationService) {
user: req.user
}
const result = await mapService.postHandler(postRequest)
if (copy) mappings[oldId] = result.data.uuid
if (copy) mappings[oldId] = result.data.id
}
}
if (results.annotations) {
......@@ -92,9 +97,10 @@ const setupArchives = function (api, mapService, annotationService) {
}
if (copy) {
annotation.target.id = mappings[annotation.target.id]
annotation.uuid = undefined
annotation.uuid = null
annotation.id = null
}
if (!annotation.author) {
if (!annotation.author || overrideAuthor) {
annotation.author = {
id: req.user.uuid,
name: req.user.profile.name
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment