Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

projects: CSV export for projects #553

Merged
merged 1 commit into from
May 25, 2021
Merged

projects: CSV export for projects #553

merged 1 commit into from
May 25, 2021

Conversation

sebdeleze
Copy link
Contributor

  • Configures a response handler to export projects record in CSV format.
  • Sets the accept mimetype in the before_request hook if a format argument is present in request.
  • Adds a CSV serializer to process records and format them in CSV row.
  • Adds the possibility to override the record resource configuration with a dedicated organisation configuration.
  • Adds a new stream response, to process a generator and customizes the attachment filename.
  • Adds manual translations to translate CSV header.
  • Closes Export search results in CSV #456.

Co-Authored-by: Sébastien Délèze [email protected]

@sebdeleze sebdeleze marked this pull request as ready for review May 7, 2021 13:52
@sebdeleze sebdeleze requested review from jma and zannkukai May 17, 2021 11:21
sonar/dedicated/hepvs/projects/resource.py Show resolved Hide resolved
"""
text = external_partner['searcherName']
if external_partner.get('institution'):
text = text + f' ({external_partner["institution"]})'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

text = ' '.join([text, external_partner["institution"]])

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

text = ' '.join([text, external_partner["institution"]])

Or:
text = f'{text} ({external_partner["institution"]})'

text = actor['choice'] if actor['choice'] != 'Other' else actor[
'other']
if actor.get('count'):
text = text + f' ({actor["count"]})'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

sonar/resources/projects/resource.py Show resolved Hide resolved
sonar/resources/projects/serializers/csv.py Show resolved Hide resolved
"""
text = external_partner['searcherName']
if external_partner.get('institution'):
text = text + f' ({external_partner["institution"]})'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

text = ' '.join([text, external_partner["institution"]])

Or:
text = f'{text} ({external_partner["institution"]})'

text = text + f' ({actor["count"]})'
return text

if data.get('innerSearcher'):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use a for loop for the next 3 if.

sonar/resources/projects/serializers/csv.py Show resolved Hide resolved
* Configures a response handler to export projects record in CSV format.
* Sets the accept mimetype in the `before_request` hook if a `format` argument is present in request.
* Adds a CSV serializer to process records and format them in CSV row.
* Adds the possibility to override the record resource configuration with a dedicated organisation configuration.
* Adds a new stream response, to process a generator and customizes the attachment filename.
* Adds manual translations to translate CSV header.
* Closes #456.

Co-Authored-by: Sébastien Délèze <[email protected]>
@sebdeleze sebdeleze merged commit a8567a5 into rero:staging May 25, 2021
@sebdeleze sebdeleze deleted the sed-hepvs-export-cvs branch May 25, 2021 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Export search results in CSV
3 participants