Skip to content
This repository has been archived by the owner on Nov 4, 2022. It is now read-only.

Commit

Permalink
Return the input institution from create/update of CKAN institution
Browse files Browse the repository at this point in the history
Institutions are not managed in CKAN, so the CKAN lib cannot know how to construct one.
  • Loading branch information
marksparkza committed Mar 11, 2021
1 parent 57aa4b4 commit 13c9428
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions odp/lib/ckan.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
import logging
from typing import List, Dict, Any
from typing import List

import ckanapi
from fastapi import HTTPException
Expand Down Expand Up @@ -423,27 +423,23 @@ def create_or_update_institution(self,
'title': institution.name,
}
try:
ckan_institution = self._call_ckan(
self._call_ckan(
'organization_create',
access_token,
**input_dict,
)
except HTTPException as e:
if e.status_code == HTTP_400_BAD_REQUEST and 'Group name already exists in database' in e.detail:
input_dict['id'] = input_dict['name']
ckan_institution = self._call_ckan(
self._call_ckan(
'organization_update',
access_token,
**input_dict,
)
else:
raise

return Institution(
key=ckan_institution['name'],
name=ckan_institution['title'],
parent_key=None,
)
return institution

def list_metadata_schemas(self,
access_token: str,
Expand Down

0 comments on commit 13c9428

Please sign in to comment.