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
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
573d242
render udf form inside study form
munnsmunns Sep 27, 2023
251ca10
Add model for saved data from UDF
munnsmunns Sep 27, 2023
5d415a3
remove duplicate widget
munnsmunns Sep 27, 2023
6bb8aa9
add todo for form tag issue
munnsmunns Sep 27, 2023
8b2e557
render saved UDF data on study detail page
munnsmunns Sep 29, 2023
9b29d5d
add mixin for adding UDF to detail pages
munnsmunns Sep 29, 2023
d1aa36d
lint
munnsmunns Sep 29, 2023
a13297b
backport changes for demo
munnsmunns Oct 27, 2023
2ba08cc
reduce queries in forms w/ UDF
munnsmunns Oct 27, 2023
8df57db
changes from review
munnsmunns Oct 27, 2023
4fc4bfe
remove generic relation
munnsmunns Oct 27, 2023
7c56a66
remove import
munnsmunns Oct 27, 2023
566e3dd
Merge branch 'main' of https://github.com/shapiromatron/hawc into udf…
munnsmunns Oct 27, 2023
c74a8aa
fix test now that rendering works properly
munnsmunns Oct 27, 2023
03acb88
fix udf detail pages
munnsmunns Oct 27, 2023
5954639
move fixture modelbinding to different assessment
munnsmunns Oct 27, 2023
8cb1286
fix tests
munnsmunns Oct 31, 2023
65af322
Merge branch 'main' into udf-render-forms
munnsmunns Oct 31, 2023
e811501
add dynamicformlisteners to necessary pages
munnsmunns Nov 1, 2023
54cdb16
Merge branch 'main' into udf-render-forms
caseyhans Jan 3, 2024
4b8a0cd
create UDFCache class
munnsmunns Jan 8, 2024
ef2de3c
add cache to endpoint form
munnsmunns Jan 8, 2024
b546ddf
set udf contents when form is saved
munnsmunns Jan 8, 2024
d4229cd
integrate cache into detail pages
munnsmunns Jan 8, 2024
e966000
delete cache for modelbinding post save
munnsmunns Jan 8, 2024
3c9b5f1
add caching to study form
munnsmunns Jan 8, 2024
26516d8
clean up cache class
munnsmunns Jan 8, 2024
d2240d5
fix content cache to work on detail pages
munnsmunns Jan 8, 2024
4b5cd46
fix attribute error and add type hints
munnsmunns Jan 8, 2024
59c685d
Merge branch 'main' into udf-render-forms
munnsmunns Jan 8, 2024
14ffe25
Merge branch 'main' into udf-render-forms
caseyhans Jan 11, 2024
80390a7
Merge branch 'main' into udf-render-forms
caseyhans Jan 12, 2024
9ca5b5b
Merge branch 'main' into udf-render-forms
caseyhans Jan 16, 2024
bd3be8b
Merge branch 'main' into udf-render-forms
caseyhans Jan 23, 2024
ba908bd
Merge branch 'main' into udf-render-forms
caseyhans Feb 9, 2024
3edb16e
format templates
caseyhans Feb 9, 2024
ea14922
fix curlies, change field name
caseyhans Feb 14, 2024
707db34
Merge branch 'main' into udf-render-forms
shapiromatron Mar 11, 2024
c242a7d
reformat test html
shapiromatron Mar 12, 2024
9a2f730
refactor common code into a form mixin
shapiromatron Mar 12, 2024
e445f72
load JS with DynamicForm or DynamicFormWidget
shapiromatron Mar 12, 2024
5534d61
add db constraint
shapiromatron Mar 12, 2024
b667ecb
rename UDF table fragment
shapiromatron Mar 12, 2024
2fe1f62
fix table template layout
shapiromatron Mar 12, 2024
6cc928d
fix unique-together constraint
shapiromatron Mar 12, 2024
780ef15
fix signals
shapiromatron Mar 12, 2024
518b4f5
bonus - improve type annotations for cacheable
shapiromatron Mar 12, 2024
1f36963
refactor cache
shapiromatron Mar 12, 2024
0a85e9d
refactor content list
shapiromatron Mar 12, 2024
10cb863
add tests
shapiromatron Mar 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion hawc/apps/udf/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.core.exceptions import PermissionDenied
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ObjectDoesNotExist, PermissionDenied
from django.urls import reverse_lazy
from django.utils.decorators import method_decorator
from django.views.generic import DetailView, ListView
Expand Down Expand Up @@ -200,3 +201,17 @@ class DeleteTagBindingView(BaseDelete):

def get_success_url(self):
return self.assessment.get_udf_list_url()


class UDFDetailMixin:
munnsmunns marked this conversation as resolved.
Show resolved Hide resolved
"""Mixin to add saved UDF contents to the context of a BaseDetail view."""

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
content_type = ContentType.objects.get_for_model(self.model)
try:
udf_binding = self.assessment.udf_bindings.get(content_type=content_type)
context["udf_content"] = udf_binding.saved_contents.get(object_id=self.object.pk)
except ObjectDoesNotExist:
context["udf_content"] = None
return context