Skip to content

Commit

Permalink
Bug/download citation not working in next (#1285)
Browse files Browse the repository at this point in the history
* commit to main

* Add useCitationMetrics hook for fetching citation metrics in publications module

* Refactor useCitationMetrics hook and update ProjectPreview module and styles

* Add MetricsModal to project modals and update Datacite API endpoints

* Refactor useCitationMetrics hook and update ProjectPreview module and styles

* Refactor ProjectCitation module and styles, and add DownloadCitation component

* Refactor ProjectCitation module and styles, and add DownloadCitation component

* chore: Refactor ProjectCitation module, add DOI link to PublishedCitation

* Refactor ProjectCitation module, add DOI link to PublishedCitation

* chore: Update Docker images and volumes configuration for development environment

* Refactor ProjectPreview module, fix useState declaration

* Refactor useState declaration in ProjectPreview module

* Refactor ProjectCitation module, optimize DOI retrieval and usage

* feat: Optimize DOI retrieval and usage in ProjectCitation module

* Refactor ProjectCitation module, optimize DOI retrieval and usage

* Refactor ProjectCitation module, remove commented out code for MetricsModal

* Refactor DOI retrieval and usage in ProjectCitation module

* test commit

* Update index.ts
  • Loading branch information
van-go authored Jun 5, 2024
1 parent 281dc93 commit 15e5100
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion designsafe/apps/api/publications/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#
# GET /listing/<file_mgr_name>/<system_id>/<file_path>/
url(r'^data-cite/events$', PublicationDataCiteEventsView.as_view(), name='publication_datacite_usage'),
url(r'^data-cite/(?P<doi>[ \S]*)$', PublicationDataCiteView.as_view(), name='publication_datacite'),
url(r'^data-cite/(?P<doi>\S+)$', PublicationDataCiteView.as_view(), name='publication_datacite'),
url(r'^(?P<operation>[\w.-]+)/$', PublicationListingView.as_view(), name='publication_listing'),
url(r'^(?P<operation>[\w.-]+)/(?P<project_id>[A-Z\-]+-[0-9]+)(v(?P<revision>[0-9]+))?/$', PublicationDetailView.as_view(), name='publication_detail'),
url(r'^(?P<operation>[\w.-]+)/(?P<project_id>[\w.-]+)/$', PublicationDetailView.as_view(), name='legacy-publication_detail')
Expand Down
9 changes: 7 additions & 2 deletions designsafe/apps/api/publications/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,16 @@ def get(self, request, operation, project_id, revision=None):
"""
class PublicationDataCiteView(BaseApiView):
def get(self, request, doi):
url = f'https://api.datacite.org/dois/{doi}'

try:
response = DataciteManager.get_doi(doi)
return JsonResponse(response)
response = requests.get(url)
response.raise_for_status() # Raises an HTTPError for bad responses (4xx and 5xx)
return JsonResponse(response.json()) # Assuming the response is JSON
except HTTPError as e:
return JsonResponse({'message': str(e)}, status=e.response.status_code)
except Exception as e:
return JsonResponse({'message': str(e)}, status=500)

"""
View for getting DataCite metrics details from publications.
Expand Down

0 comments on commit 15e5100

Please sign in to comment.