***
Wartungsfenster jeden ersten Mittwoch vormittag im Monat
***
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Invenio Utilities TUW
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Center for Research Data Management
Invenio Utilities TUW
Commits
725a4bb1
Commit
725a4bb1
authored
4 years ago
by
Moser, Maximilian
Browse files
Options
Downloads
Patches
Plain Diff
Calculate creatibutor name from given_name and family_name
parent
97b9fafd
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
invenio_utilities_tuw/cli/drafts.py
+4
-0
4 additions, 0 deletions
invenio_utilities_tuw/cli/drafts.py
invenio_utilities_tuw/cli/records.py
+2
-0
2 additions, 0 deletions
invenio_utilities_tuw/cli/records.py
invenio_utilities_tuw/cli/utils.py
+25
-0
25 additions, 0 deletions
invenio_utilities_tuw/cli/utils.py
with
31 additions
and
0 deletions
invenio_utilities_tuw/cli/drafts.py
+
4
−
0
View file @
725a4bb1
...
@@ -32,6 +32,7 @@ from .utils import (
...
@@ -32,6 +32,7 @@ from .utils import (
get_identity_for_user
,
get_identity_for_user
,
patch_metadata
,
patch_metadata
,
read_metadata
,
read_metadata
,
set_creatibutor_names
,
set_record_owners
,
set_record_owners
,
)
)
...
@@ -99,6 +100,7 @@ def create_draft(metadata_path, publish, user, owners, vanity_pid):
...
@@ -99,6 +100,7 @@ def create_draft(metadata_path, publish, user, owners, vanity_pid):
if
owners
:
if
owners
:
metadata
=
set_record_owners
(
metadata
,
owners
)
metadata
=
set_record_owners
(
metadata
,
owners
)
metadata
=
set_creatibutor_names
(
metadata
)
draft
=
create_record_from_metadata
(
metadata
,
identity
,
vanity_pid
=
vanity_pid
)
draft
=
create_record_from_metadata
(
metadata
,
identity
,
vanity_pid
=
vanity_pid
)
recid
=
draft
[
"
id
"
]
recid
=
draft
[
"
id
"
]
...
@@ -112,6 +114,7 @@ def create_draft(metadata_path, publish, user, owners, vanity_pid):
...
@@ -112,6 +114,7 @@ def create_draft(metadata_path, publish, user, owners, vanity_pid):
if
owners
:
if
owners
:
metadata
=
set_record_owners
(
metadata
,
owners
)
metadata
=
set_record_owners
(
metadata
,
owners
)
metadata
=
set_creatibutor_names
(
metadata
)
draft
=
create_record_from_metadata
(
metadata
,
identity
)
draft
=
create_record_from_metadata
(
metadata
,
identity
)
recid
=
draft
[
"
id
"
]
recid
=
draft
[
"
id
"
]
file_names
=
[]
file_names
=
[]
...
@@ -196,6 +199,7 @@ def update_draft(metadata_file, pid, pid_type, user, patch, owners):
...
@@ -196,6 +199,7 @@ def update_draft(metadata_file, pid, pid_type, user, patch, owners):
owners
=
[
get_identity_for_user
(
owner
)
for
owner
in
owners
]
owners
=
[
get_identity_for_user
(
owner
)
for
owner
in
owners
]
metadata
=
set_record_owners
(
metadata
,
owners
)
metadata
=
set_record_owners
(
metadata
,
owners
)
metadata
=
set_creatibutor_names
(
metadata
)
service
.
update_draft
(
id_
=
pid
,
identity
=
identity
,
data
=
metadata
)
service
.
update_draft
(
id_
=
pid
,
identity
=
identity
,
data
=
metadata
)
click
.
secho
(
pid
,
fg
=
"
green
"
)
click
.
secho
(
pid
,
fg
=
"
green
"
)
...
...
This diff is collapsed.
Click to expand it.
invenio_utilities_tuw/cli/records.py
+
2
−
0
View file @
725a4bb1
...
@@ -29,6 +29,7 @@ from .utils import (
...
@@ -29,6 +29,7 @@ from .utils import (
get_identity_for_user
,
get_identity_for_user
,
get_object_uuid
,
get_object_uuid
,
patch_metadata
,
patch_metadata
,
set_creatibutor_names
,
set_record_owners
,
set_record_owners
,
)
)
...
@@ -112,6 +113,7 @@ def update_record(metadata_file, pid, pid_type, user, patch, owners):
...
@@ -112,6 +113,7 @@ def update_record(metadata_file, pid, pid_type, user, patch, owners):
owners
=
[
get_identity_for_user
(
owner
)
for
owner
in
owners
]
owners
=
[
get_identity_for_user
(
owner
)
for
owner
in
owners
]
metadata
=
set_record_owners
(
metadata
,
owners
)
metadata
=
set_record_owners
(
metadata
,
owners
)
metadata
=
set_creatibutor_names
(
metadata
)
service
.
update
(
id_
=
pid
,
identity
=
identity
,
data
=
metadata
)
service
.
update
(
id_
=
pid
,
identity
=
identity
,
data
=
metadata
)
click
.
secho
(
pid
,
fg
=
"
green
"
)
click
.
secho
(
pid
,
fg
=
"
green
"
)
...
...
This diff is collapsed.
Click to expand it.
invenio_utilities_tuw/cli/utils.py
+
25
−
0
View file @
725a4bb1
...
@@ -133,3 +133,28 @@ def set_record_owners(record_metadata, owners):
...
@@ -133,3 +133,28 @@ def set_record_owners(record_metadata, owners):
metadata
[
"
access
"
][
"
owned_by
"
]
=
owners
metadata
[
"
access
"
][
"
owned_by
"
]
=
owners
return
metadata
return
metadata
def
_set_creatibutor_name
(
creatibutor
):
"""
Set the name from the given_name and family_name from the creator/contributor.
"""
creatibutor
=
creatibutor
.
get
(
"
person_or_org
"
,
{})
name
=
creatibutor
.
get
(
"
name
"
)
if
not
name
:
given_name
=
creatibutor
.
get
(
"
given_name
"
)
family_name
=
creatibutor
.
get
(
"
family_name
"
)
if
given_name
and
family_name
:
creatibutor
[
"
name
"
]
=
"
{}, {}
"
.
format
(
family_name
,
given_name
)
def
set_creatibutor_names
(
record_metadata
):
"""
Set the name field for each creator and contributor if they
'
re not set.
"""
metadata
=
record_metadata
.
copy
()
for
creator
in
metadata
.
get
(
"
metadata
"
,
{}).
get
(
"
creators
"
,
[]):
_set_creatibutor_name
(
creator
)
for
contributor
in
metadata
.
get
(
"
metadata
"
,
{}).
get
(
"
contributors
"
,
[]):
_set_creatibutor_name
(
contributor
)
return
metadata
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment