Commit 2fc23bd6 authored by Andreas Wagner's avatar Andreas Wagner
Browse files

Add doPublish query parameter.

parent 7cd68d6a
......@@ -35,6 +35,7 @@ func SetupRoutes(conf tei2zenodo.Config) *gin.Engine {
var myResult tei2zenodo.Result
var r io.ReadSeeker
var doPublish bool
// Read file from Request body
buf := new(bytes.Buffer)
......@@ -49,10 +50,16 @@ func SetupRoutes(conf tei2zenodo.Config) *gin.Engine {
r.Seek(0, 0)
}
// log.Printf("Beginning of submitted file %s: %s ...", filename, file[:100])
// Get doPublish from request (false if not set)
if c.Request.FormValue(`doPublish`) == "True" {
doPublish = true
} else {
doPublish = false
}
// Parse TEI file
log.Printf("=== Parse TEI file ===")
// log.Printf("Beginning of submitted file %s: %s ...", filename, file[:100])
mc := conf.Metadata
var md tei2zenodo.ZMetadata
doi, err := t2zxml.ParseTEI(r, &md, &mc)
......@@ -117,12 +124,16 @@ func SetupRoutes(conf tei2zenodo.Config) *gin.Engine {
return
}
log.Printf("=== Publish at zenodo ===")
err = zenodo.Publish(&md, &conf.Repo)
if err != nil {
log.Printf("Error publishing deposit: %v", err)
AbortMsg(500, err, c)
return
if doPublish {
log.Printf("=== Publish at zenodo ===")
err = zenodo.Publish(&md, &conf.Repo)
if err != nil {
log.Printf("Error publishing deposit: %v", err)
AbortMsg(500, err, c)
return
}
} else {
log.Printf("=== Not published. If you want to publish, set doPublish=True as request parameter. ===")
}
log.Printf("=== All done ===")
......
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