Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
On Thursday, 7th July from 1 to 3 pm there will be a maintenance with a short downtime of GitLab.
Open sidebar
nomad-lab
nomad-FAIR
Commits
7b5a77a9
Commit
7b5a77a9
authored
Mar 02, 2021
by
Markus Scheidgen
Browse files
Fixed wrong mongodb key for doi metadata.
parent
859715d0
Pipeline
#94805
passed with stages
in 23 minutes and 16 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nomad/doi.py
View file @
7b5a77a9
...
...
@@ -24,7 +24,7 @@ import xml.etree.ElementTree as ET
import
datetime
import
requests
from
requests.auth
import
HTTPBasicAuth
from
mongoengine
import
Document
,
StringField
,
DateTimeField
,
BinaryField
from
mongoengine
import
Document
,
StringField
,
DateTimeField
from
mongoengine.errors
import
NotUniqueError
from
nomad.datamodel
import
User
...
...
@@ -70,7 +70,7 @@ class DOI(Document):
doi_url
=
StringField
()
state
=
StringField
()
create_time
=
DateTimeField
()
m
a
tadata_xml
=
Binary
Field
()
m
e
tadata_xml
=
String
Field
()
@
staticmethod
def
create
(
title
:
str
,
user
:
User
)
->
'DOI'
:
...
...
@@ -124,7 +124,7 @@ class DOI(Document):
_xml
(
mds_resource
,
'publisher'
,
'NOMAD Repository'
)
_xml
(
mds_resource
,
'publicationYear'
,
str
(
datetime
.
datetime
.
now
().
year
))
doi
.
metadata_xml
=
ET
.
tostring
(
mds_resource
,
encoding
=
'UTF-8'
,
method
=
'xml'
)
doi
.
metadata_xml
=
ET
.
tostring
(
mds_resource
,
encoding
=
'UTF-8'
,
method
=
'xml'
)
.
decode
(
'utf-8'
)
doi
.
save
()
return
doi
...
...
@@ -146,7 +146,7 @@ class DOI(Document):
response
=
requests
.
post
(
self
.
metadata_url
,
headers
=
{
'Content-Type'
:
'application/xml;charset=UTF-8'
},
data
=
self
.
metadata_xml
,
**
_requests_args
())
data
=
self
.
metadata_xml
.
encode
(
'utf-8'
)
,
**
_requests_args
())
if
self
.
__handle_datacite_errors
(
response
,
'create draft DOI'
):
self
.
state
=
'draft'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment