diff --git a/anatomy/static/js/upload_form_helpers.js b/anatomy/static/js/upload_form_helpers.js
index 4e74615e..7172a06e 100644
--- a/anatomy/static/js/upload_form_helpers.js
+++ b/anatomy/static/js/upload_form_helpers.js
@@ -1,4 +1,4 @@
- let active_file_inputs = new Set();
+ var active_file_inputs = new Set();
function add_input_form() {
var form_idx = $('#id_images-TOTAL_FORMS').val();
diff --git a/rapids/forms.py b/rapids/forms.py
index 3917a639..4bc9c27c 100755
--- a/rapids/forms.py
+++ b/rapids/forms.py
@@ -25,6 +25,10 @@ from django.contrib.admin.widgets import FilteredSelectMultiple
from django.forms.widgets import RadioSelect, TextInput, Textarea
from django.contrib.auth.models import User
+from crispy_forms.helper import FormHelper
+from crispy_forms.layout import Submit, Layout, Div, Field, HTML
+from crispy_forms.bootstrap import InlineRadios
+
class RapidAnswerForm(ModelForm):
class Meta:
@@ -97,25 +101,50 @@ class RapidForm(ModelForm):
ModelForm.__init__(self, *args, **kwargs)
super(RapidForm, self).__init__(*args, **kwargs)
- # self.fields['question'].widget.attrs = {'class': 'question-form', 'rows': 10, 'cols': 100}
- # self.fields['feedback'].widget.attrs = {'class': 'feedback-form', 'rows': 10, 'cols': 100}
+
+
+ self.helper = FormHelper()
+ self.helper.form_id = 'id-anatomy-question-form'
+ self.helper.form_tag = False
+
+ self.helper.layout = Layout(
+ Div(InlineRadios('normal')),
+ Div(
+ HTML("
Abnormality
"),
+ Field('abnormality', css_class='form-control'),
+ HTML("Region
"),
+ Field('region', css_class='form-control'),
+ css_class='clearfix abnormal-fields'
+ ),
+ HTML("Examination*
"),
+ Field('examination', css_class='form-control'),
+ Div(InlineRadios('laterality', css_class='form-control'), css_class='clearfix clear-both'),
+ Field('feedback', css_class='form-control'),
+ Field('history', css_class='form-control'),
+ Field('open_access', css_class='form-control'),
+ HTML("Exams
"),
+ Field('exams', css_class='form-control'),
+ )
self.fields["abnormality"] = ModelMultipleChoiceField(
required=False,
queryset=Abnormality.objects.all(),
widget=FilteredSelectMultiple(verbose_name="Abnormality", is_stacked=False),
)
+ self.fields["abnormality"].label = ""
self.fields["region"] = ModelMultipleChoiceField(
required=False,
queryset=Region.objects.all(),
widget=FilteredSelectMultiple(verbose_name="Region", is_stacked=False),
)
+ self.fields["region"].label = ""
self.fields["examination"] = ModelMultipleChoiceField(
queryset=Examination.objects.all(),
widget=FilteredSelectMultiple(verbose_name="Examination", is_stacked=False),
)
+ self.fields["examination"].label = ""
self.fields["laterality"] = ChoiceField(
choices=Rapid.LATERALITY_CHOICES, required=False, widget=RadioSelect()
@@ -133,6 +162,7 @@ class RapidForm(ModelForm):
queryset=exam_queryset.distinct(),
widget=FilteredSelectMultiple(verbose_name="Exams", is_stacked=False),
)
+ self.fields["exams"].label = ""
def save(self, commit=True):
instance = ModelForm.save(self, False)
@@ -186,11 +216,8 @@ class RapidForm(ModelForm):
]
# fields = ['question', 'feedback', 'subspecialty', 'references']
widgets = {
- # "normal": RadioSelect(
- # choices=[(True, 'Yes'),
- # (False, 'No')])
- }
-
+ "normal": RadioSelect()
+ }
ImageFormSet = inlineformset_factory(
Rapid,
diff --git a/rapids/migrations/0015_alter_rapid_normal.py b/rapids/migrations/0015_alter_rapid_normal.py
new file mode 100644
index 00000000..4c44dd40
--- /dev/null
+++ b/rapids/migrations/0015_alter_rapid_normal.py
@@ -0,0 +1,18 @@
+# Generated by Django 5.0.2 on 2024-10-21 09:11
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('rapids', '0014_exam_exam_open_access'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='rapid',
+ name='normal',
+ field=models.BooleanField(choices=[(True, 'Normal'), (False, 'Abnormal')], default=False, help_text='Defines if a question is normal/abnormal'),
+ ),
+ ]
diff --git a/rapids/models.py b/rapids/models.py
index e8a2e705..0e1d0ee5 100644
--- a/rapids/models.py
+++ b/rapids/models.py
@@ -161,7 +161,12 @@ class Rapid(QuestionBase):
question = models.TextField(null=True, blank=True)
history = models.TextField(null=True, blank=True)
- normal = models.BooleanField(default=False, help_text="Tick if true")
+ NORMAL_CHOICES = (
+ (True, "Normal"),
+ (False, "Abnormal"),
+ )
+
+ normal = models.BooleanField(default=False, help_text="Defines if a question is normal/abnormal", choices=NORMAL_CHOICES)
NONE = "NONE"
LEFT = "LEFT"
diff --git a/rapids/templates/rapids/rapid_form.html b/rapids/templates/rapids/rapid_form.html
index 2a400fec..df19a973 100755
--- a/rapids/templates/rapids/rapid_form.html
+++ b/rapids/templates/rapids/rapid_form.html
@@ -1,11 +1,11 @@
{% extends "rapids/base.html" %}
{% load static from static %}
+{% load crispy_forms_tags %}
{% block js %}
+
{{ form.media }}
{% endblock %}
+
{% block content %}
{% if object %}
@@ -380,7 +333,7 @@ the feedback image box is checked they will not be displayed when taking the que
No directory monitored
-->