From 3ab40304a39a4cf7aa501380d90c24c2e226c957 Mon Sep 17 00:00:00 2001 From: Ross Date: Tue, 27 Feb 2024 21:57:15 +0000 Subject: [PATCH] Add an option to edit the author of cases/collections --- atlas/forms.py | 11 +++++++++++ atlas/templates/atlas/case_detail.html | 1 + atlas/templates/atlas/collection_headers.html | 4 +++- atlas/urls.py | 2 ++ atlas/views.py | 16 ++++++++++++++-- templates/author_form.html | 19 +++++++++++++++++++ 6 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 templates/author_form.html diff --git a/atlas/forms.py b/atlas/forms.py index 86838269..bdc6572e 100755 --- a/atlas/forms.py +++ b/atlas/forms.py @@ -51,6 +51,8 @@ from autocomplete import widgets as htmx_widgets import logging +from generic.forms import ExamAuthorFormMixin + class ConditionForm(ModelForm): class Meta: model = Condition @@ -626,3 +628,12 @@ class ConditionAutocompleteForm(Form): condition = ModelChoiceField(queryset=Condition.objects.all(), widget=htmx_widgets.Autocomplete( name="conditions", options=dict(model=Condition) )) + + +class CaseCollectionAuthorForm(ExamAuthorFormMixin): + class Meta(ExamAuthorFormMixin.Meta): + model = CaseCollection + +class CaseAuthorForm(ExamAuthorFormMixin): + class Meta(ExamAuthorFormMixin.Meta): + model = Case \ No newline at end of file diff --git a/atlas/templates/atlas/case_detail.html b/atlas/templates/atlas/case_detail.html index 14f392a2..2736a407 100755 --- a/atlas/templates/atlas/case_detail.html +++ b/atlas/templates/atlas/case_detail.html @@ -12,6 +12,7 @@ Add Note + Authors {% if request.user.is_superuser %} Admin Edit {% endif %} diff --git a/atlas/templates/atlas/collection_headers.html b/atlas/templates/atlas/collection_headers.html index 27631f79..27ded27e 100644 --- a/atlas/templates/atlas/collection_headers.html +++ b/atlas/templates/atlas/collection_headers.html @@ -4,11 +4,13 @@ Mark / Scores / Candidates / - Add New Case + Add New Case / + Authors
Edit \ Delete \ Clone + {% if request.user.is_superuser %} \ Admin Edit {% endif %} diff --git a/atlas/urls.py b/atlas/urls.py index 6cbb0d2e..f37c2467 100755 --- a/atlas/urls.py +++ b/atlas/urls.py @@ -68,6 +68,7 @@ urlpatterns = [ views.collection_take_start, name="collection_take_start", ), + path("collection//authors", views.CaseCollectionAuthorUpdate.as_view(), name="collection_authors"), path( "collection//cids", views.GenericExamViews.exam_cids, @@ -153,6 +154,7 @@ urlpatterns = [ views.collection_dicom_json, name="collection_dicom_json", ), + path("case//authors", views.CaseAuthorUpdate.as_view(), name="case_authors"), path( "case//dicom_json", views.case_dicom_json, diff --git a/atlas/views.py b/atlas/views.py index fa1869fa..39ed04d8 100755 --- a/atlas/views.py +++ b/atlas/views.py @@ -34,6 +34,8 @@ from generic.models import CidUser, CidUserExam from .forms import ( AddCollectionToCaseForm, + CaseAuthorForm, + CaseCollectionAuthorForm, CaseCollectionCaseFormSet, CaseCollectionForm, CaseForm, @@ -124,7 +126,7 @@ import logging from copy import deepcopy from django.forms.models import model_to_dict -from generic.views import ExamCloneMixin, ExamViews, SeriesImagesZipViewBase +from generic.views import AuthorRequiredMixin, ExamCloneMixin, ExamViews, SeriesImagesZipViewBase from reversion.views import RevisionMixin import reversion @@ -2239,4 +2241,14 @@ def combine_series(request): series.delete() return HttpResponse(f"Series {series_ids} combines") - #return HttpResponse("Fail") \ No newline at end of file + #return HttpResponse("Fail") + +class CaseCollectionAuthorUpdate(RevisionMixin, AuthorRequiredMixin, UpdateView): + model = CaseCollection + form_class = CaseCollectionAuthorForm + template_name = "author_form.html" + +class CaseAuthorUpdate(RevisionMixin, AuthorRequiredMixin, UpdateView): + model = Case + form_class = CaseAuthorForm + template_name = "author_form.html" \ No newline at end of file diff --git a/templates/author_form.html b/templates/author_form.html new file mode 100644 index 00000000..e1e49897 --- /dev/null +++ b/templates/author_form.html @@ -0,0 +1,19 @@ + +{% extends "base.html" %} + +{% block js %} + {{ form.media }} +{% endblock %} + +{% block content %} + +

Edit Authors

+
+ {% csrf_token %} + + {{ form.as_table }} +
+ + Cancel +
+{% endblock %}