.
This commit is contained in:
+2
-2
@@ -9,7 +9,7 @@ from .models import (
|
|||||||
Modality,
|
Modality,
|
||||||
Region,
|
Region,
|
||||||
BodyPart,
|
BodyPart,
|
||||||
Structure2,
|
Structure,
|
||||||
)
|
)
|
||||||
|
|
||||||
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(Structure2)
|
admin.site.register(Structure)
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -14,7 +14,7 @@ from .models import (
|
|||||||
AnatomyQuestion,
|
AnatomyQuestion,
|
||||||
#Examination,
|
#Examination,
|
||||||
BodyPart,
|
BodyPart,
|
||||||
Structure2,
|
Structure,
|
||||||
Region,
|
Region,
|
||||||
Modality,
|
Modality,
|
||||||
QuestionType,
|
QuestionType,
|
||||||
@@ -86,7 +86,7 @@ class AnatomyQuestionForm(ModelForm):
|
|||||||
queryset=Modality.objects.all(),
|
queryset=Modality.objects.all(),
|
||||||
)
|
)
|
||||||
|
|
||||||
#self.fields["Structure2"] = ModelChoiceField(
|
#self.fields["Structure"] = ModelChoiceField(
|
||||||
# required=False,
|
# required=False,
|
||||||
# queryset=Structure.objects.all(),
|
# queryset=Structure.objects.all(),
|
||||||
#)
|
#)
|
||||||
@@ -197,9 +197,9 @@ class ExaminationForm(ModelForm):
|
|||||||
fields = ["examination"]
|
fields = ["examination"]
|
||||||
|
|
||||||
|
|
||||||
class Structure2Form(ModelForm):
|
class StructureForm(ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Structure2
|
model = Structure
|
||||||
fields = ["structure"]
|
fields = ["structure"]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# Generated by Django 3.2.8 on 2021-10-25 10:08
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('anatomy', '0049_delete_structure'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameModel(
|
||||||
|
old_name='Structure2',
|
||||||
|
new_name='Structure',
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# Generated by Django 3.2.8 on 2021-10-25 10:08
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('anatomy', '0050_rename_structure2_structure'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='anatomyquestion',
|
||||||
|
name='structure',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='anatomy.structure'),
|
||||||
|
),
|
||||||
|
]
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
|
|
||||||
from anatomy.models import Structure2
|
from anatomy.models import Structure
|
||||||
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.Structure2Autocomplete.as_view(model=Structure2, create_field='structure'),
|
views.StructureAutocomplete.as_view(model=Structure, create_field='structure'),
|
||||||
name="structure-autocomplete",
|
name="structure-autocomplete",
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
+9
-9
@@ -34,7 +34,7 @@ from .forms import (
|
|||||||
ExaminationForm,
|
ExaminationForm,
|
||||||
MarkAnatomyQuestionForm,
|
MarkAnatomyQuestionForm,
|
||||||
AnatomyQuestionForm,
|
AnatomyQuestionForm,
|
||||||
Structure2Form,
|
StructureForm,
|
||||||
ExamForm,
|
ExamForm,
|
||||||
)
|
)
|
||||||
from .models import (
|
from .models import (
|
||||||
@@ -42,7 +42,7 @@ from .models import (
|
|||||||
BodyPart,
|
BodyPart,
|
||||||
CidUserAnswer,
|
CidUserAnswer,
|
||||||
# Examination,
|
# Examination,
|
||||||
Structure2,
|
Structure,
|
||||||
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 = Structure2Form(request.POST or None)
|
form = StructureForm(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": "Structure2"}
|
request, "anatomy/create_simple.html", {"form": form, "name": "Structure"}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -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 = Structure2.objects.get(name=structure_name).id
|
structure_id = Structure.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 Structure2Autocomplete(autocomplete.Select2QuerySetView):
|
class StructureAutocomplete(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 Structure2.objects.none()
|
return Structure.objects.none()
|
||||||
|
|
||||||
qs = Structure2.objects.all()
|
qs = Structure.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 Structure2.objects.none()
|
return Structure.objects.none()
|
||||||
|
|
||||||
|
|
||||||
return qs
|
return qs
|
||||||
|
|||||||
Reference in New Issue
Block a user