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

Use HTMX for PRIMED-specific audit buttons #456

Merged
merged 29 commits into from
Feb 27, 2024
Merged

Conversation

amstilp
Copy link
Contributor

@amstilp amstilp commented Feb 20, 2024

Use htmx to handle the audit resolution for CDSA, dbGaP, and collaborative analysis workspaces audits. Make parallel changes for all the apps so they work similarly.

  • Install the django-htmx app in the project. This app adds an "htmx" attribute to the request.
  • Add a new view to resolve an audit instead of linking to the GroupGroupMembershipCreate by parent and child page from ACM. This view can handle htmx requests or regular requests. This is also a little safer because it doesn't have the dropdown to select a role, so groups can only be added as members of another group (which is what we want).
  • Add an html snippet for the audit resolve buttons.
  • Modify the audit classes to work better with the above flow.

Implement the above changes for the following apps:

  • cdsa
  • dbgap
  • collaborative_anlaysis
  • Rearrange templates into nested snippets dirs
  • Move anvil_create call to after full_clean and save
  • Use shared text from a template snippet on all audit pages for a given app

Closes #122

This new structure is more intuitive when we add a "resolve" url
and view.
This view re-runs the audit and takes the appropriate action. In
future commits we can add htmx functionality to this view. Part of
this view meant reworking the audit structure itself. Use the same
action url for all types of AccessAuditResult and set the action
text in subclasses. Add str methods for the audit result classes
so the text can be displayed on the audit resolve page. Finally,
add a get_all_results method to the audit class that returns the
concatenation of audit results for all SignedAgreements.
Add an html snippet that renders the button based on the table
record. This will make it easier to replace with htmx.
In the action column of the SignedAgreementAudit tables, post directly
to the view that resolves the audit by modifying the template column
to use a form instead of a link button to the audit resolve view.
As part of this (and for temporarily interactive testing) comment
out the parts of the view that make API calls to AnVIL. This causes
the tests to fail (as desired, so I remember to uncomment them later.)
Install the django-htmx package into the project settings file.
Check whether the request is htmx in the view, and if it is, return
an htmx response that replaces the button with appropriate text.
This is pretty simple; just need to add the hx-disabled-elt attribute
to to the html. No jquery required!
Copy link

codecov bot commented Feb 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.59%. Comparing base (7d81e7f) to head (15ab60a).
Report is 27 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #456      +/-   ##
==========================================
+ Coverage   98.46%   98.59%   +0.13%     
==========================================
  Files         262      274      +12     
  Lines       20002    21505    +1503     
==========================================
+ Hits        19694    21202    +1508     
+ Misses        308      303       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

This way, if we change it anywhere, we only have to change it in one
place.
The script used the wrong group as a (second) auth domain.
Add a view that runs an audit on a specific CDSA workpsace and
(if a post request) handles that audit appropriately. The view can
also handle htmx requests. Modify the workspace_audit classes for
CDSA workspaces as necessary to achieve this: add a str method that
can be displayed on the detail page; set the "action" text for
different classes with a default, and change the action_url to be
the same for all the different types of audit result classes. Add a
get_all_results method to the WorkspaceAccessAudit class.
I also had to rename the template for the signed agreement audit
action button, since it can't be reused by both signed agreements
and workspaces. This commit also implements the htmx tags for CDSA
workspace audit handling.
Add a view that runs an audit on a specific dbGaPApplication and
dbGaPWorkspace and (if a post request) handles that audit appopriately.
The view can also handle htmx requests. Modify the workspace audit
classes for dbGaPWorkspaces as necessary to achieve this: add a str
method that can be displayed on the detail page; set the "action"
text for different classes with a default, and change the action_url
to be the same for all the different types of audit result classes.
Add a get_all_results method to the dbGaPAccessAudit class.
Instead of auditing the group access in the _audit_workspace method,
add a specific method that will audit the access to a collaborative
analysis workspace for a group.
Add a view that runs an audit on a specific email and
CollaborativeAnalysisWorkspace and (if a post request) handles that
audit appopriately. The view can also handle htmx requests. Modify
the workspace audit classes for CollaborativeAnalsyisWorkspaces as
necessary to achieve this: add a str method that can be displayed on
the detail page; set the "action" text for different classes with a
default, and change the action_url to be the same for all the
different types of audit result classes. Add a get_all_results method
to the CollaborativeAnalysisWorkspaceAccessAudit class.
Only call the AnVIL create/delete methods after the local create/
delete methods when resolving an audit.
@amstilp amstilp marked this pull request as ready for review February 27, 2024 23:34
@amstilp amstilp merged commit aace8af into main Feb 27, 2024
8 checks passed
@amstilp amstilp deleted the feature/htmx-audits branch April 22, 2024 19:07
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.

htmx(?) and dbGaP application audit page
1 participant