move anatomy structure to atlas
This commit is contained in:
@@ -9,7 +9,6 @@ from .models import (
|
|||||||
#Modality,
|
#Modality,
|
||||||
Region,
|
Region,
|
||||||
BodyPart,
|
BodyPart,
|
||||||
Structure,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
from generic.models import Examination
|
from generic.models import Examination
|
||||||
@@ -58,5 +57,4 @@ admin.site.register(UserAnswer)
|
|||||||
admin.site.register(Exam, ExamAdmin)
|
admin.site.register(Exam, ExamAdmin)
|
||||||
admin.site.register(Region)
|
admin.site.register(Region)
|
||||||
admin.site.register(BodyPart)
|
admin.site.register(BodyPart)
|
||||||
admin.site.register(Structure)
|
|
||||||
|
|
||||||
|
|||||||
+2
-8
@@ -16,7 +16,7 @@ from .models import (
|
|||||||
AnatomyQuestion,
|
AnatomyQuestion,
|
||||||
# Examination,
|
# Examination,
|
||||||
BodyPart,
|
BodyPart,
|
||||||
Structure,
|
#Structure,
|
||||||
Region,
|
Region,
|
||||||
Modality,
|
Modality,
|
||||||
QuestionType,
|
QuestionType,
|
||||||
@@ -150,7 +150,7 @@ class AnatomyQuestionForm(ModelForm):
|
|||||||
]
|
]
|
||||||
|
|
||||||
widgets = {
|
widgets = {
|
||||||
"structure": autocomplete.ModelSelect2(url="anatomy:structure-autocomplete")
|
"structure": autocomplete.ModelSelect2(url="atlas:structure-autocomplete")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -191,12 +191,6 @@ class ExaminationForm(ModelForm):
|
|||||||
fields = ["examination"]
|
fields = ["examination"]
|
||||||
|
|
||||||
|
|
||||||
class StructureForm(ModelForm):
|
|
||||||
class Meta:
|
|
||||||
model = Structure
|
|
||||||
fields = ["structure"]
|
|
||||||
|
|
||||||
|
|
||||||
class BodyPartForm(ModelForm):
|
class BodyPartForm(ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = BodyPart
|
model = BodyPart
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
# Generated by Django 4.1.4 on 2024-01-10 23:12
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('atlas', '0037_alter_seriesimage_image_blake3_hash'),
|
||||||
|
('anatomy', '0005_exam_stats_graph'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='anatomyquestion',
|
||||||
|
name='structure',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='atlas.structure'),
|
||||||
|
),
|
||||||
|
migrations.DeleteModel(
|
||||||
|
name='Structure',
|
||||||
|
),
|
||||||
|
]
|
||||||
+1
-17
@@ -17,6 +17,7 @@ from sortedm2m.fields import SortedManyToManyField
|
|||||||
import string
|
import string
|
||||||
|
|
||||||
from generic.models import CidUser, CidUserGroup, ExamUserStatus, Examination, ExamBase, QuestionBase, QuestionNote, UserAnswerBase, UserUserGroup, Modality
|
from generic.models import CidUser, CidUserGroup, ExamUserStatus, Examination, ExamBase, QuestionBase, QuestionNote, UserAnswerBase, UserUserGroup, Modality
|
||||||
|
from atlas.models import Structure
|
||||||
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from helpers.images import image_as_base64
|
from helpers.images import image_as_base64
|
||||||
@@ -47,13 +48,6 @@ class BodyPart(models.Model):
|
|||||||
return self.bodypart
|
return self.bodypart
|
||||||
|
|
||||||
|
|
||||||
class Structure(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)
|
||||||
|
|
||||||
@@ -139,16 +133,6 @@ class AnatomyQuestion(QuestionBase):
|
|||||||
self.modality,
|
self.modality,
|
||||||
self.structure,
|
self.structure,
|
||||||
)
|
)
|
||||||
# Get associated exams
|
|
||||||
e = self.exams.all().values_list("name", flat=True)
|
|
||||||
exams = ", ".join(e)
|
|
||||||
|
|
||||||
if a is None:
|
|
||||||
return "({})".format(exams)
|
|
||||||
else:
|
|
||||||
return "{} ({}) [{}, {}]".format(
|
|
||||||
a.answer, exams, self.modality, self.structure
|
|
||||||
)
|
|
||||||
|
|
||||||
def get_link(self):
|
def get_link(self):
|
||||||
return format_html("<a href='{}'>{}</a>", self.get_absolute_url(), self)
|
return format_html("<a href='{}'>{}</a>", self.get_absolute_url(), self)
|
||||||
|
|||||||
@@ -54,9 +54,9 @@ def create_exam(db):
|
|||||||
|
|
||||||
|
|
||||||
def create_structures(db):
|
def create_structures(db):
|
||||||
structure = Structure.objects.create(structure="test structure")
|
structure = Structure.objects.create(name="test structure")
|
||||||
structure.save()
|
structure.save()
|
||||||
structure = Structure.objects.create(structure="test structure 2")
|
structure = Structure.objects.create(name="test structure 2")
|
||||||
structure.save()
|
structure.save()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
|
|
||||||
from anatomy.models import Structure
|
|
||||||
from generic.urls import generic_exam_urls, generic_view_urls
|
from generic.urls import generic_exam_urls, generic_view_urls
|
||||||
from . import views
|
from . import views
|
||||||
from django.views.decorators.cache import cache_page
|
from django.views.decorators.cache import cache_page
|
||||||
@@ -59,12 +58,6 @@ urlpatterns = [
|
|||||||
views.get_body_part_id,
|
views.get_body_part_id,
|
||||||
name="get_body_part_id",
|
name="get_body_part_id",
|
||||||
),
|
),
|
||||||
path("structure/create/", views.create_structure, name="create_structure"),
|
|
||||||
path(
|
|
||||||
"structure/ajax/get_structure_id",
|
|
||||||
views.get_structure_id,
|
|
||||||
name="get_structure_id",
|
|
||||||
),
|
|
||||||
path("examination/create/", views.create_examination, name="create_examination"),
|
path("examination/create/", views.create_examination, name="create_examination"),
|
||||||
path(
|
path(
|
||||||
"examination/ajax/get_examination_id",
|
"examination/ajax/get_examination_id",
|
||||||
@@ -84,11 +77,6 @@ urlpatterns = [
|
|||||||
views.UserAnswerDelete.as_view(),
|
views.UserAnswerDelete.as_view(),
|
||||||
name="user_answer_delete",
|
name="user_answer_delete",
|
||||||
),
|
),
|
||||||
path(
|
|
||||||
"structure-autocomplete",
|
|
||||||
views.StructureAutocomplete.as_view(model=Structure, create_field="structure"),
|
|
||||||
name="structure-autocomplete",
|
|
||||||
),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
urlpatterns.extend(generic_view_urls(views.GenericViews))
|
urlpatterns.extend(generic_view_urls(views.GenericViews))
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ from .forms import (
|
|||||||
ExaminationForm,
|
ExaminationForm,
|
||||||
MarkAnatomyQuestionForm,
|
MarkAnatomyQuestionForm,
|
||||||
AnatomyQuestionForm,
|
AnatomyQuestionForm,
|
||||||
StructureForm,
|
|
||||||
ExamForm,
|
ExamForm,
|
||||||
)
|
)
|
||||||
from .models import (
|
from .models import (
|
||||||
@@ -674,18 +673,6 @@ def get_examination_id(request):
|
|||||||
return HttpResponse("/")
|
return HttpResponse("/")
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
|
||||||
def create_structure(request):
|
|
||||||
form = StructureForm(request.POST or None)
|
|
||||||
if form.is_valid():
|
|
||||||
instance = form.save()
|
|
||||||
return HttpResponse(
|
|
||||||
'<script>opener.closePopup(window, "%s", "%s", "#id_structure");</script>'
|
|
||||||
% (instance.pk, instance)
|
|
||||||
)
|
|
||||||
return render(
|
|
||||||
request, "anatomy/create_simple.html", {"form": form, "name": "Structure"}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
@@ -807,20 +794,3 @@ GenericViews = GenericViewBase("anatomy", AnatomyQuestion, UserAnswer, Exam)
|
|||||||
class ExamClone(ExamCloneMixin, ExamCreate):
|
class ExamClone(ExamCloneMixin, ExamCreate):
|
||||||
"""Clone exam view"""
|
"""Clone exam view"""
|
||||||
|
|
||||||
|
|
||||||
class StructureAutocomplete(autocomplete.Select2QuerySetView):
|
|
||||||
def get_queryset(self):
|
|
||||||
# Don't forget to filter out results depending on the visitor !
|
|
||||||
if not self.request.user.is_authenticated:
|
|
||||||
return Structure.objects.none()
|
|
||||||
|
|
||||||
qs = Structure.objects.all()
|
|
||||||
|
|
||||||
if self.q:
|
|
||||||
# This raises a fielderror which breaks creating a new item if not caught
|
|
||||||
try:
|
|
||||||
qs = qs.filter(structure__icontains=self.q)
|
|
||||||
except FieldError:
|
|
||||||
return Structure.objects.none()
|
|
||||||
|
|
||||||
return qs
|
|
||||||
|
|||||||
Reference in New Issue
Block a user