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

Add UDF to study and endpoint forms #906

Merged
merged 50 commits into from
Mar 12, 2024
Merged

Add UDF to study and endpoint forms #906

merged 50 commits into from
Mar 12, 2024

Conversation

munnsmunns
Copy link
Collaborator

@munnsmunns munnsmunns commented Sep 27, 2023

  • Add model for saved UDF data, ModelUDFContent
  • Add UDF functionality to the Animal Endpoint form and Study form
  • UDF data is saved/initialized properly
  • UDF data is displayed on the detail pages. Adds a Mixin which adds UDF data to the view context

@shapiromatron
Copy link
Owner

I think this needs a little more work - can this be updated and completed? I made a few edits in a scratch branch to get the conditional form logic working for the demo, but it may need to be added elsewhere too:

  • f105ecd wip (3 days ago) {Andy Shapiro}

Copy link
Owner

@shapiromatron shapiromatron left a comment

Choose a reason for hiding this comment

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

Let's try to get this one wrapped up! We can start here and then do the UDF tags next.

hawc/apps/udf/templates/udf/fragments/_udf_content.html Outdated Show resolved Hide resolved
@munnsmunns munnsmunns marked this pull request as ready for review October 27, 2023 21:19
@munnsmunns munnsmunns marked this pull request as draft October 30, 2023 13:42
@munnsmunns munnsmunns marked this pull request as ready for review October 31, 2023 21:30
@shapiromatron
Copy link
Owner

I haven't had time to do the work, but I did a code review of this PR and it's looking great so far. I think one thing we need to add is some caching mechanism to cache the UDF for each assessment, so we don't have as many database hits to see if each model type has a related UDF or not.

It might be as simple as following a pattern similar to assessment/permissions.py to make a new class with some of this information. It could perhaps have a cache key like assessment-123-udf, and it has a property for content_ids = [1,2,3] and tag_ids = [3,4,5] that lists the content types and tags that have related UDF. We could add a signal to clear the cache whenever ModelBinding or TagBinding changes for a given assessment.

Copy link
Owner

@shapiromatron shapiromatron left a comment

Choose a reason for hiding this comment

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

I made a number of changes; see below. In general, try to generalize methods where possible; it's good that we had a Mixin for adding UDF on the detail view, but we needed the same thing to add to any Model Form; the way it was implemented as proposed required us to make lots of repetitive inline changes to each model form.

I also figured out how to auto-add the JS to the form pages; this was worth a read - Media.

@shapiromatron shapiromatron merged commit 5d79fc9 into main Mar 12, 2024
6 checks passed
@shapiromatron shapiromatron deleted the udf-render-forms branch March 12, 2024 21:26
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

3 participants