.
This commit is contained in:
+2
-2
@@ -9,7 +9,7 @@ from .models import (
|
||||
Modality,
|
||||
Region,
|
||||
BodyPart,
|
||||
Structure2,
|
||||
Structure,
|
||||
)
|
||||
|
||||
from generic.models import Examination
|
||||
@@ -59,5 +59,5 @@ admin.site.register(Exam, ExamAdmin)
|
||||
admin.site.register(Modality)
|
||||
admin.site.register(Region)
|
||||
admin.site.register(BodyPart)
|
||||
admin.site.register(Structure2)
|
||||
admin.site.register(Structure)
|
||||
|
||||
|
||||
+4
-4
@@ -14,7 +14,7 @@ from .models import (
|
||||
AnatomyQuestion,
|
||||
#Examination,
|
||||
BodyPart,
|
||||
Structure2,
|
||||
Structure,
|
||||
Region,
|
||||
Modality,
|
||||
QuestionType,
|
||||
@@ -86,7 +86,7 @@ class AnatomyQuestionForm(ModelForm):
|
||||
queryset=Modality.objects.all(),
|
||||
)
|
||||
|
||||
#self.fields["Structure2"] = ModelChoiceField(
|
||||
#self.fields["Structure"] = ModelChoiceField(
|
||||
# required=False,
|
||||
# queryset=Structure.objects.all(),
|
||||
#)
|
||||
@@ -197,9 +197,9 @@ class ExaminationForm(ModelForm):
|
||||
fields = ["examination"]
|
||||
|
||||
|
||||
class Structure2Form(ModelForm):
|
||||
class StructureForm(ModelForm):
|
||||
class Meta:
|
||||
model = Structure2
|
||||
model = 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 anatomy.models import Structure2
|
||||
from anatomy.models import Structure
|
||||
from . import views
|
||||
from django.views.decorators.cache import cache_page
|
||||
|
||||
@@ -151,7 +151,7 @@ urlpatterns = [
|
||||
),
|
||||
path(
|
||||
"structure-autocomplete",
|
||||
views.Structure2Autocomplete.as_view(model=Structure2, create_field='structure'),
|
||||
views.StructureAutocomplete.as_view(model=Structure, create_field='structure'),
|
||||
name="structure-autocomplete",
|
||||
),
|
||||
]
|
||||
|
||||
+9
-9
@@ -34,7 +34,7 @@ from .forms import (
|
||||
ExaminationForm,
|
||||
MarkAnatomyQuestionForm,
|
||||
AnatomyQuestionForm,
|
||||
Structure2Form,
|
||||
StructureForm,
|
||||
ExamForm,
|
||||
)
|
||||
from .models import (
|
||||
@@ -42,7 +42,7 @@ from .models import (
|
||||
BodyPart,
|
||||
CidUserAnswer,
|
||||
# Examination,
|
||||
Structure2,
|
||||
Structure,
|
||||
Exam,
|
||||
Answer,
|
||||
# HalfMarkAnswers,
|
||||
@@ -872,7 +872,7 @@ def get_examination_id(request):
|
||||
|
||||
@login_required
|
||||
def create_structure(request):
|
||||
form = Structure2Form(request.POST or None)
|
||||
form = StructureForm(request.POST or None)
|
||||
if form.is_valid():
|
||||
instance = form.save()
|
||||
return HttpResponse(
|
||||
@@ -880,7 +880,7 @@ def create_structure(request):
|
||||
% (instance.pk, instance)
|
||||
)
|
||||
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):
|
||||
if request.is_ajax():
|
||||
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 = {
|
||||
"structure_id": structure_id,
|
||||
}
|
||||
@@ -1003,20 +1003,20 @@ class ExamClone(ExamCloneMixin, ExamCreate):
|
||||
"""Clone exam view"""
|
||||
|
||||
|
||||
class Structure2Autocomplete(autocomplete.Select2QuerySetView):
|
||||
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 Structure2.objects.none()
|
||||
return Structure.objects.none()
|
||||
|
||||
qs = Structure2.objects.all()
|
||||
qs = Structure.objects.all()
|
||||
|
||||
if self.q:
|
||||
# This raises a fielderror which breaks creating a new item if not caught
|
||||
try:
|
||||
qs = qs.filter(name__istartswith=self.q)
|
||||
except FieldError:
|
||||
return Structure2.objects.none()
|
||||
return Structure.objects.none()
|
||||
|
||||
|
||||
return qs
|
||||
|
||||
Reference in New Issue
Block a user