diff --git a/src/pyflask/apis/__init__.py b/src/pyflask/apis/__init__.py index 178515427..1334f2626 100644 --- a/src/pyflask/apis/__init__.py +++ b/src/pyflask/apis/__init__.py @@ -10,4 +10,5 @@ from .apiDatasets import api as datasets_resource from .apiCollections import api as collections_resource from .apiSkeleton import api as skeleton_resource -from .apiUploadManifests import api as upload_manifest_resource \ No newline at end of file +from .apiUploadManifests import api as upload_manifest_resource +from .apiContributors import api as contributors_resource \ No newline at end of file diff --git a/src/pyflask/apis/apiContributors.py b/src/pyflask/apis/apiContributors.py new file mode 100644 index 000000000..5e3c010a6 --- /dev/null +++ b/src/pyflask/apis/apiContributors.py @@ -0,0 +1,2 @@ +from flask_restx import Resource, fields, reqparse +from contributors import get_workspace_contributors, create_workspace_contributors \ No newline at end of file diff --git a/src/pyflask/contributors/__init__.py b/src/pyflask/contributors/__init__.py new file mode 100644 index 000000000..6ec35eb33 --- /dev/null +++ b/src/pyflask/contributors/__init__.py @@ -0,0 +1 @@ +from .contributors import (get_workspace_contributors, create_workspace_contributors) \ No newline at end of file diff --git a/src/pyflask/contributors/contributors.py b/src/pyflask/contributors/contributors.py new file mode 100644 index 000000000..063a12eac --- /dev/null +++ b/src/pyflask/contributors/contributors.py @@ -0,0 +1,34 @@ +import requests +from authentication import get_access_token +from utils import create_request_headers +from namespaces import NamespaceEnum, get_namespace_logger +from constants import PENNSIEVE_URL + + +namespace_logger = get_namespace_logger(NamespaceEnum.MANAGE_DATASETS) + +def get_workspace_contributors(): + try: + r = requests.get(f'{PENNSIEVE_URL}/contributors') + r.raise_for_status() + return r.json() + except Exception as e: + namespace_logger.error(e) + + +def create_workspace_contributors(contributors): + try: + for con in contributors: + payload = { + "email": con['email'], + "lastName": con['last_name'], + "firstName": con['first_name'], + "orcid": con['orcid'] + } + + # TODO: Handle if they contributor already exists? + r = requests.post(f'{PENNSIEVE_URL}/contributors', json=payload, headers=create_request_headers(get_access_token())) + r.raise_for_status() + except Exception as e: + namespace_logger.error(e) + raise e \ No newline at end of file diff --git a/src/renderer/src/scripts/guided-mode/guided-curate-dataset.js b/src/renderer/src/scripts/guided-mode/guided-curate-dataset.js index 712d3e4e4..3f79a1818 100644 --- a/src/renderer/src/scripts/guided-mode/guided-curate-dataset.js +++ b/src/renderer/src/scripts/guided-mode/guided-curate-dataset.js @@ -9322,6 +9322,7 @@ const handleAddContributorHeaderUI = () => { `; }); + // TODO: publishing-rework-end-to-end - Change the dropdown to include all organization wide contributors return `