diff --git a/CHANGELOG.md b/CHANGELOG.md index e4a7f45..3591d77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +## [v0.3.2](https://github.com/UAL-RE/ldcoolp-figshare/tree/v0.3.2) (2021-07-07) + +**Implemented enhancements:** + - Add method to retrieve ORCID and Figshare account ID for users + [#27](https://github.com/UAL-RE/ldcoolp-figshare/pull/27) + +**Closed issues:** + - Add method to retrieve ORCID and Figshare account ID for users + [#26](https://github.com/UAL-RE/ldcoolp-figshare/issues/26) + + ## [v0.3.1](https://github.com/UAL-RE/ldcoolp-figshare/tree/v0.3.1) (2021-07-01) **Merged pull requests:** diff --git a/docs/source/conf.py b/docs/source/conf.py index daa37ff..1052053 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -24,7 +24,7 @@ author = 'Chun Ly, UA Research Data Repository (ReDATA) Team' # The full version, including alpha/beta/rc tags -release = 'v0.3.1' +release = 'v0.3.2' # -- General configuration --------------------------------------------------- diff --git a/ldcoolp_figshare/__init__.py b/ldcoolp_figshare/__init__.py index 1e07a42..7021114 100644 --- a/ldcoolp_figshare/__init__.py +++ b/ldcoolp_figshare/__init__.py @@ -1,3 +1,3 @@ -__version__ = "0.3.1" +__version__ = "0.3.2" from .main import FigshareInstituteAdmin diff --git a/ldcoolp_figshare/main.py b/ldcoolp_figshare/main.py index 5c72e19..6c15b76 100644 --- a/ldcoolp_figshare/main.py +++ b/ldcoolp_figshare/main.py @@ -106,7 +106,7 @@ def get_user_articles(self, account_id: int, process: bool = True) \ See: https://docs.figshare.com/#private_articles_list - :param account_id: Figshare account ID + :param account_id: Figshare *institute* account ID :param process: Returns JSON content from ``redata_request``, otherwise the full request is provided. Default: True @@ -135,7 +135,7 @@ def get_user_projects(self, account_id: int, process: bool = True) \ See: https://docs.figshare.com/#private_projects_list - :param account_id: Figshare account ID + :param account_id: Figshare *institute* account ID :param process: Returns JSON content from ``redata_request``, otherwise the full request is provided. Default: True @@ -164,7 +164,7 @@ def get_user_collections(self, account_id: int, process: bool = True) \ See: https://docs.figshare.com/#private_collections_list - :param account_id: Figshare account ID + :param account_id: Figshare *institute* account ID :param process: Returns JSON content from ``redata_request``, otherwise the full request is provided. Default: True @@ -253,7 +253,7 @@ def get_account_group_roles(self, account_id: int, process: bool = True) \ See: https://docs.figshare.com/#private_institution_account_group_roles - :param account_id: Figshare account ID + :param account_id: Figshare *institute* account ID :param process: Returns JSON content from ``redata_request``, otherwise the full request is provided. Default: True @@ -289,6 +289,9 @@ def get_account_details(self, flag: bool = True) -> pd.DataFrame: num_projects = np.zeros(n_accounts, dtype=np.intc) num_collections = np.zeros(n_accounts, dtype=np.intc) + orcid_num = [''] * n_accounts + user_id = np.zeros(n_accounts, dtype=np.intc) # This is the Figshare user ID + if flag: admin_flag = [''] * n_accounts reviewer_flag = [''] * n_accounts @@ -296,6 +299,11 @@ def get_account_details(self, flag: bool = True) -> pd.DataFrame: # Determine group roles for each account for n, account_id in zip(range(n_accounts), accounts_df['id']): + # Save ORCID and account ID + other_account_dict = self.get_other_account_details(account_id) + orcid_num[n] = other_account_dict['orcid_id'] + user_id[n] = other_account_dict['id'] + roles = self.get_account_group_roles(account_id) try: @@ -336,6 +344,9 @@ def get_account_details(self, flag: bool = True) -> pd.DataFrame: accounts_df['Projects'] = num_projects accounts_df['Collections'] = num_collections + accounts_df['ORCID'] = orcid_num + accounts_df['user_id'] = user_id + if flag: accounts_df['Admin'] = admin_flag accounts_df['Reviewer'] = reviewer_flag @@ -348,6 +359,23 @@ def get_account_details(self, flag: bool = True) -> pd.DataFrame: accounts_df['Group'] = group_assoc return accounts_df + def get_other_account_details(self, account_id: int) -> dict: + """ + Retrieve ORCID and Figshare account information (among other metadata) + + See: https://docs.figshare.com/#private_account_institution_user + + :param account_id: Figshare *institute* account ID + + :return: Dictionary with full account details + """ + + url = self.endpoint(f"users/{account_id}", institute=True) + + other_account_dict = redata_request('GET', url, self.headers) + + return other_account_dict + def get_curation_list(self, article_id: int = None, status: Optional[str] = "", process: bool = True) \ -> Union[pd.DataFrame, Response]: diff --git a/setup.py b/setup.py index 1ac5e41..e2fe40a 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setup( name='ldcoolp-figshare', - version='0.3.1', + version='0.3.2', packages=find_namespace_packages(), url='https://github.com/UAL-RE/ldcoolp-figshare/', project_urls={