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
base: development
Are you sure you want to change the base?
Conversation
- 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.
Still TODO: - Use trait_utils where relevant in My Trait Library code - Use display name(s) in My Trait Library
Moves display name logic to that file, so calling files don't have to worry about three-part name structure
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
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
user-provided value
There was a problem hiding this comment.
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
.
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
user-provided value
There was a problem hiding this comment.
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.
(Would prefer to merge #472 into dev and handle conflicts in this branch)