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

Draft the My Trait Library widget #475

Open
wants to merge 46 commits into
base: development
Choose a base branch
from

Conversation

vlagrassa
Copy link
Collaborator

@vlagrassa vlagrassa commented Apr 17, 2024

  • Re-organizes and modularizes some of the trait querying endpoints
  • Modularizes a lot of the Phenotype Database table code
  • Uses both of the above to create a rough draft of the MTL widget

(Would prefer to merge #472 into dev and handle conflicts in this branch)

- Actually add the species filter to the `query`
- Make sure `tags` is defined before trying to take length
Instead of splitting on dataset ('caendr' and 'zhang'), there are now two endpoints for different return formats: SQL-style pagination and JS DataTable-style pagination.

Both endpoints accept a `dataset` URL var that filters the query to that dataset.
Split into `public`, `private`, and `all` endpoints, all handled by the same view functions.  Roughly, these control whether the server should include private traits in the response, and require different levels of permission:

  - `public`:  Queries traits that have been submitted to the public phenotype database.
  - `private`: Queries all traits that belong to the requesting user. Log-in required.
  - `all`:     Queries all traits that have been uploaded. Admin users only.
Accepts argument `include_private`, which will determine whether private (unpublished) traits should be available to the query or not.

For now, this argument doesn't do anything.
@vlagrassa vlagrassa requested a review from r-vieira April 17, 2024 22:01
@vlagrassa vlagrassa marked this pull request as ready for review April 18, 2024 22:14
Primarily brings `trait_id` table column into this branch. Still have to propagate this to all areas, e.g. selecting a trait in the table using `trait_id` instead of `trait_name_caendr`
Using the unique `trait_id` is cleaner
Comment on lines +239 to +251
return {
'data': [
tr.to_json() for tr in pagination.items
],
'pagination': {
'has_next': pagination.has_next,
'has_prev': pagination.has_prev,
'prev_num': pagination.prev_num,
'next_num': pagination.next_num,
'total_pages': pagination.pages,
'current_page': current_page
},
}

Check warning

Code scanning / CodeQL

Reflected server-side cross-site scripting Medium

Cross-site scripting vulnerability due to a
user-provided value
.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Values are cleaned using bleach in the helper function get_clean.

Comment on lines +352 to +359
return {
'data': [
trait.to_json_with_values() for trait in data
],
'draw': draw,
'recordsTotal': total_records,
'recordsFiltered': filtered_records,
}

Check warning

Code scanning / CodeQL

Reflected server-side cross-site scripting Medium

Cross-site scripting vulnerability due to a
user-provided value
.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Values are cleaned using bleach in the helper function get_clean.

A number of endpoints (i.e. tool submissions) have a standard set of error fields they might return, so this pulls that all together.  Also means tool submissions now scroll to the top when an error message appears, which is nice.
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.

None yet

1 participant