.
This commit is contained in:
+2
-2
@@ -9,7 +9,7 @@ from .models import (
|
|||||||
Modality,
|
Modality,
|
||||||
Region,
|
Region,
|
||||||
BodyPart,
|
BodyPart,
|
||||||
Structure,
|
Structure2,
|
||||||
)
|
)
|
||||||
|
|
||||||
from generic.models import Examination
|
from generic.models import Examination
|
||||||
@@ -59,5 +59,5 @@ admin.site.register(Exam, ExamAdmin)
|
|||||||
admin.site.register(Modality)
|
admin.site.register(Modality)
|
||||||
admin.site.register(Region)
|
admin.site.register(Region)
|
||||||
admin.site.register(BodyPart)
|
admin.site.register(BodyPart)
|
||||||
admin.site.register(Structure)
|
admin.site.register(Structure2)
|
||||||
|
|
||||||
|
|||||||
+7
-7
@@ -14,7 +14,7 @@ from .models import (
|
|||||||
AnatomyQuestion,
|
AnatomyQuestion,
|
||||||
#Examination,
|
#Examination,
|
||||||
BodyPart,
|
BodyPart,
|
||||||
Structure,
|
Structure2,
|
||||||
Region,
|
Region,
|
||||||
Modality,
|
Modality,
|
||||||
QuestionType,
|
QuestionType,
|
||||||
@@ -86,7 +86,7 @@ class AnatomyQuestionForm(ModelForm):
|
|||||||
queryset=Modality.objects.all(),
|
queryset=Modality.objects.all(),
|
||||||
)
|
)
|
||||||
|
|
||||||
#self.fields["structure"] = ModelChoiceField(
|
#self.fields["Structure2"] = ModelChoiceField(
|
||||||
# required=False,
|
# required=False,
|
||||||
# queryset=Structure.objects.all(),
|
# queryset=Structure.objects.all(),
|
||||||
#)
|
#)
|
||||||
@@ -148,7 +148,7 @@ class AnatomyQuestionForm(ModelForm):
|
|||||||
"image",
|
"image",
|
||||||
"region",
|
"region",
|
||||||
"modality",
|
"modality",
|
||||||
"structure",
|
"Structure2",
|
||||||
"examination",
|
"examination",
|
||||||
"body_part",
|
"body_part",
|
||||||
"description",
|
"description",
|
||||||
@@ -156,7 +156,7 @@ class AnatomyQuestionForm(ModelForm):
|
|||||||
]
|
]
|
||||||
|
|
||||||
widgets = {
|
widgets = {
|
||||||
"structure" : autocomplete.ModelSelect2(url='anatomy:structure-autocomplete')
|
"Structure2" : autocomplete.ModelSelect2(url='anatomy:Structure2-autocomplete')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -197,10 +197,10 @@ class ExaminationForm(ModelForm):
|
|||||||
fields = ["examination"]
|
fields = ["examination"]
|
||||||
|
|
||||||
|
|
||||||
class StructureForm(ModelForm):
|
class Structure2Form(ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Structure
|
model = Structure2
|
||||||
fields = ["structure"]
|
fields = ["Structure2"]
|
||||||
|
|
||||||
|
|
||||||
class BodyPartForm(ModelForm):
|
class BodyPartForm(ModelForm):
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
# Generated by Django 3.2.8 on 2021-10-25 10:02
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('anatomy', '0047_auto_20211022_2038'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Structure2',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('structure', models.CharField(max_length=200, unique=True)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='anatomyquestion',
|
||||||
|
name='structure',
|
||||||
|
field=models.CharField(max_length=255, null=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
+10
-2
@@ -48,6 +48,11 @@ class Structure(models.Model):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.structure
|
return self.structure
|
||||||
|
|
||||||
|
class Structure2(models.Model):
|
||||||
|
structure = models.CharField(max_length=200, unique=True)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.structure
|
||||||
|
|
||||||
class Region(models.Model):
|
class Region(models.Model):
|
||||||
region = models.CharField(max_length=200)
|
region = models.CharField(max_length=200)
|
||||||
@@ -110,8 +115,11 @@ class AnatomyQuestion(models.Model):
|
|||||||
body_part = models.ForeignKey(
|
body_part = models.ForeignKey(
|
||||||
BodyPart, on_delete=models.SET_NULL, null=True, blank=True
|
BodyPart, on_delete=models.SET_NULL, null=True, blank=True
|
||||||
)
|
)
|
||||||
structure = models.ForeignKey(
|
#structure = models.ForeignKey(
|
||||||
Structure, on_delete=models.SET_NULL, null=True, blank=True
|
# Structure, on_delete=models.SET_NULL, null=True, blank=True
|
||||||
|
#)
|
||||||
|
structure = models.CharField(
|
||||||
|
max_length=255, null=True
|
||||||
)
|
)
|
||||||
created_date = models.DateTimeField(default=timezone.now)
|
created_date = models.DateTimeField(default=timezone.now)
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
|
|
||||||
from anatomy.models import Structure
|
from anatomy.models import Structure2
|
||||||
from . import views
|
from . import views
|
||||||
from django.views.decorators.cache import cache_page
|
from django.views.decorators.cache import cache_page
|
||||||
|
|
||||||
@@ -151,7 +151,7 @@ urlpatterns = [
|
|||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
"structure-autocomplete",
|
"structure-autocomplete",
|
||||||
views.StructureAutocomplete.as_view(model=Structure, create_field='structure'),
|
views.Structure2Autocomplete.as_view(model=Structure2, create_field='structure'),
|
||||||
name="structure-autocomplete",
|
name="structure-autocomplete",
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
+9
-9
@@ -34,7 +34,7 @@ from .forms import (
|
|||||||
ExaminationForm,
|
ExaminationForm,
|
||||||
MarkAnatomyQuestionForm,
|
MarkAnatomyQuestionForm,
|
||||||
AnatomyQuestionForm,
|
AnatomyQuestionForm,
|
||||||
StructureForm,
|
Structure2Form,
|
||||||
ExamForm,
|
ExamForm,
|
||||||
)
|
)
|
||||||
from .models import (
|
from .models import (
|
||||||
@@ -42,7 +42,7 @@ from .models import (
|
|||||||
BodyPart,
|
BodyPart,
|
||||||
CidUserAnswer,
|
CidUserAnswer,
|
||||||
# Examination,
|
# Examination,
|
||||||
Structure,
|
Structure2,
|
||||||
Exam,
|
Exam,
|
||||||
Answer,
|
Answer,
|
||||||
# HalfMarkAnswers,
|
# HalfMarkAnswers,
|
||||||
@@ -872,7 +872,7 @@ def get_examination_id(request):
|
|||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def create_structure(request):
|
def create_structure(request):
|
||||||
form = StructureForm(request.POST or None)
|
form = Structure2Form(request.POST or None)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
instance = form.save()
|
instance = form.save()
|
||||||
return HttpResponse(
|
return HttpResponse(
|
||||||
@@ -880,7 +880,7 @@ def create_structure(request):
|
|||||||
% (instance.pk, instance)
|
% (instance.pk, instance)
|
||||||
)
|
)
|
||||||
return render(
|
return render(
|
||||||
request, "anatomy/create_simple.html", {"form": form, "name": "Structure"}
|
request, "anatomy/create_simple.html", {"form": form, "name": "Structure2"}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -888,7 +888,7 @@ def create_structure(request):
|
|||||||
def get_structure_id(request):
|
def get_structure_id(request):
|
||||||
if request.is_ajax():
|
if request.is_ajax():
|
||||||
structure_name = request.GET["structure_name"]
|
structure_name = request.GET["structure_name"]
|
||||||
structure_id = Structure.objects.get(name=structure_name).id
|
structure_id = Structure2.objects.get(name=structure_name).id
|
||||||
data = {
|
data = {
|
||||||
"structure_id": structure_id,
|
"structure_id": structure_id,
|
||||||
}
|
}
|
||||||
@@ -1003,20 +1003,20 @@ class ExamClone(ExamCloneMixin, ExamCreate):
|
|||||||
"""Clone exam view"""
|
"""Clone exam view"""
|
||||||
|
|
||||||
|
|
||||||
class StructureAutocomplete(autocomplete.Select2QuerySetView):
|
class Structure2Autocomplete(autocomplete.Select2QuerySetView):
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
# Don't forget to filter out results depending on the visitor !
|
# Don't forget to filter out results depending on the visitor !
|
||||||
if not self.request.user.is_authenticated:
|
if not self.request.user.is_authenticated:
|
||||||
return Structure.objects.none()
|
return Structure2.objects.none()
|
||||||
|
|
||||||
qs = Structure.objects.all()
|
qs = Structure2.objects.all()
|
||||||
|
|
||||||
if self.q:
|
if self.q:
|
||||||
# This raises a fielderror which breaks creating a new item if not caught
|
# This raises a fielderror which breaks creating a new item if not caught
|
||||||
try:
|
try:
|
||||||
qs = qs.filter(name__istartswith=self.q)
|
qs = qs.filter(name__istartswith=self.q)
|
||||||
except FieldError:
|
except FieldError:
|
||||||
return Structure.objects.none()
|
return Structure2.objects.none()
|
||||||
|
|
||||||
|
|
||||||
return qs
|
return qs
|
||||||
|
|||||||
Reference in New Issue
Block a user