This commit is contained in:
Ross
2021-02-05 11:28:05 +00:00
parent d8167aa95f
commit 542848f4d0
7 changed files with 68 additions and 6 deletions
+22
View File
@@ -0,0 +1,22 @@
from django.forms import (
Form,
ModelForm,
ModelMultipleChoiceField,
ModelChoiceField,
ChoiceField,
CharField,
)
from django.forms import inlineformset_factory
from generic.models import (
Examination,
)
from django.contrib.admin.widgets import FilteredSelectMultiple
from django.forms.widgets import RadioSelect, TextInput, Textarea
class ExaminationForm(ModelForm):
class Meta:
model = Examination
fields = ["examination"]
+14
View File
@@ -0,0 +1,14 @@
from django.urls import path, include
from . import views
app_name = "generic"
urlpatterns = [
# path('', views.question_list, name='question_list'),
path("examination/create/",
views.create_examination,
name="create_examination"),
path("examination/ajax/get_examination_id",
views.get_examination_id,
name="get_examination_id"),
]
+24
View File
@@ -1,3 +1,27 @@
from django.shortcuts import render
# Create your views here.
@login_required
def create_examination(request):
form = ExaminationForm(request.POST or None)
if form.is_valid():
instance = form.save()
return HttpResponse(
'<script>opener.closePopup(window, "%s", "%s", "#id_examination");</script>'
% (instance.pk, instance)
)
return render(
request, "rapids/create_simple.html", {"form": form, "name": "Examination"}
)
@csrf_exempt
def get_examination_id(request):
if request.is_ajax():
examination_name = request.GET["examination_name"]
examination_id = Examination.objects.get(name=examination_name).id
data = {
"examination_id": examination_id,
}
return HttpResponse(json.dumps(data), content_type="application/json")
return HttpResponse("/")
+2 -2
View File
@@ -127,8 +127,8 @@ class LongSeries(models.Model):
modality = models.ForeignKey(Modality, related_name="series_modality", on_delete=models.SET_NULL, null=True)
examination = models.ForeignKey(
Examination, help_text="Name of the examination", related_name="series_examination", on_delete=models.SET_NULL, null=True)
long = models.ForeignKey("Long", related_name="series", on_delete=models.SET_NULL, null=True)
description = models.TextField(blank=True, help_text="Description of stack, for admin organisation")
long = models.ForeignKey("Long", help_text="The question this series should be associated with", related_name="series", on_delete=models.SET_NULL, null=True)
description = models.TextField(blank=True, help_text="Description of stack, for admin organisation, will not be visible when taking")
def get_examinations(self):
"""Returns a comma seperated text list of regions"""
+1
View File
@@ -20,6 +20,7 @@ Longs:
<a href="{% url 'longs:exam_list' %}">Exams</a> /
<a href="{% url 'longs:long_view' %}">Questions</a> /
<a href="{% url 'longs:long_create' %}" title="Create a new question">Create Question</a>
<a href="{% url 'longs:long_series_create' %}" title="Create a new image series">Create Series</a>
{% endif %}
{% comment %} </br>
Questions by:
+4 -3
View File
@@ -39,9 +39,7 @@
$(document).ready(function () {
$("#add_abnormality").appendTo($("label[for='id_abnormality']"));
$("#add_examination").appendTo($("label[for='id_examination']"));
$("#add_region").appendTo($("label[for='id_region']"));
dropContainer = document.getElementById("drop-container");
@@ -281,9 +279,12 @@
{% endblock %}
{% block content %}
<h2>Add Series</h2>
<a href="{% url 'longs:long_create_defaults' %}">Edit defaults</a>
<!-- <a href="{% url 'longs:long_create_defaults' %}">Edit defaults</a> -->
This form will create a image set that can be associated with a long question. If the question has already been created it can be linked below.
<form action="" method="post" enctype="multipart/form-data" id="long-form">
{% csrf_token %}
<a href="/generic/examination/create" id="add_examination" class="add-popup"
onclick="return showAddPopup(this);"><img src="{% static '/img/icon-addlink.svg' %}"></a>
<table>
{{ form.as_table }}
</table>
+1 -1
View File
@@ -238,7 +238,7 @@
<a href="{% url 'rapids:rapid_create_defaults' %}">Edit defaults</a>
<form action="" method="post" enctype="multipart/form-data" id="rapid-form">
{% csrf_token %}
<a href="/rapids/abnormality/create" id="add_abnormality" class="add-popup"
<a href="/generic/abnormality/create" id="add_abnormality" class="add-popup"
onclick="return showAddPopup(this);"><img src="{% static '/img/icon-addlink.svg' %}"></a>
<a href="/rapids/examination/create" id="add_examination" class="add-popup"
onclick="return showAddPopup(this);"><img src="{% static '/img/icon-addlink.svg' %}"></a>