This commit is contained in:
Ross
2021-12-07 15:23:24 +00:00
parent db05b04b5f
commit 2f2b3a4ef3
6 changed files with 63 additions and 31 deletions
+6 -8
View File
@@ -9,7 +9,7 @@ from .models import (
Finding, Finding,
SeriesFinding, SeriesFinding,
Structure, Structure,
PathalogicalProcess, PathologicalProcess,
Presentation, Presentation,
) )
@@ -35,13 +35,14 @@ admin.site.register(Finding)
admin.site.register(Structure) admin.site.register(Structure)
admin.site.register(SeriesFinding) admin.site.register(SeriesFinding)
admin.site.register(Differential) admin.site.register(Differential)
admin.site.register(PathalogicalProcess) admin.site.register(PathologicalProcess)
admin.site.register(Presentation) admin.site.register(Presentation)
class DifferentialInline(admin.TabularInline): class DifferentialInline(admin.TabularInline):
model = Differential model = Differential
class AtlasAdminForm(ModelForm): class AtlasAdminForm(ModelForm):
class Meta: class Meta:
model = Case model = Case
@@ -62,8 +63,8 @@ class AtlasAdminForm(ModelForm):
# "normal": RadioSelect( # "normal": RadioSelect(
# choices=[(True, 'Yes'), # choices=[(True, 'Yes'),
# (False, 'No')]) # (False, 'No')])
"history": TinyMCE(attrs={"cols": 80, "rows": 30}), "history": TinyMCE(attrs={"cols": 80, "rows": 30}),
"discussion": TinyMCE(attrs={"cols": 80, "rows": 30}), "discussion": TinyMCE(attrs={"cols": 80, "rows": 30}),
} }
@@ -74,10 +75,7 @@ class AtlasAdmin(VersionAdmin):
save_as = True save_as = True
view_on_site = True view_on_site = True
inlines = ( inlines = (DifferentialInline,)
DifferentialInline,
)
admin.site.register(Case, AtlasAdmin) admin.site.register(Case, AtlasAdmin)
+20 -4
View File
@@ -1,6 +1,15 @@
import django_filters import django_filters
from .models import Case, Condition, Finding, PathalogicalProcess, Presentation, Series, Structure, Subspecialty from .models import (
Case,
Condition,
Finding,
PathologicalProcess,
Presentation,
Series,
Structure,
Subspecialty,
)
from django.contrib.auth.models import User from django.contrib.auth.models import User
@@ -23,13 +32,18 @@ class CaseFilter(django_filters.FilterSet):
differential_case = django_filters.ModelMultipleChoiceFilter( differential_case = django_filters.ModelMultipleChoiceFilter(
label="Differential", label="Differential",
field_name="differentialcase__condition", field_name="differentialcase__condition",
#to_field_name="differential", # to_field_name="differential",
queryset=Condition.objects.all(), queryset=Condition.objects.all(),
) )
class Meta: class Meta:
model = Case model = Case
fields = ("created_date", "open_access", "author", "differential_case") # "site", fields = (
"created_date",
"open_access",
"author",
"differential_case",
) # "site",
def __init__( def __init__(
self, self,
@@ -135,6 +149,7 @@ class StructureFilter(django_filters.FilterSet):
) )
pass pass
class PresentationFilter(django_filters.FilterSet): class PresentationFilter(django_filters.FilterSet):
class Meta: class Meta:
model = Presentation model = Presentation
@@ -157,7 +172,7 @@ class PresentationFilter(django_filters.FilterSet):
class PathologicalProcessFilter(django_filters.FilterSet): class PathologicalProcessFilter(django_filters.FilterSet):
class Meta: class Meta:
model = PathalogicalProcess model = PathologicalProcess
fields = ("name",) fields = ("name",)
def __init__( def __init__(
@@ -174,6 +189,7 @@ class PathologicalProcessFilter(django_filters.FilterSet):
) )
pass pass
class SubspecialtyFilter(django_filters.FilterSet): class SubspecialtyFilter(django_filters.FilterSet):
class Meta: class Meta:
model = Subspecialty model = Subspecialty
@@ -0,0 +1,17 @@
# Generated by Django 3.2.8 on 2021-12-07 15:23
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('atlas', '0020_rename_pathalogical_process_case_pathological_process'),
]
operations = [
migrations.RenameModel(
old_name='PathalogicalProcess',
new_name='PathologicalProcess',
),
]
+2 -2
View File
@@ -163,7 +163,7 @@ class Subspecialty(models.Model):
return format_html("<a href='{}'>{}</a>", self.get_absolute_url(), self.name) return format_html("<a href='{}'>{}</a>", self.get_absolute_url(), self.name)
class PathalogicalProcess(models.Model): class PathologicalProcess(models.Model):
name = models.CharField(max_length=255) name = models.CharField(max_length=255)
def __str__(self) -> str: def __str__(self) -> str:
@@ -230,7 +230,7 @@ class Case(models.Model):
presentation = models.ManyToManyField(Presentation, blank=True) presentation = models.ManyToManyField(Presentation, blank=True)
pathological_process = models.ManyToManyField(PathalogicalProcess, blank=True) pathological_process = models.ManyToManyField(PathologicalProcess, blank=True)
differential = models.ManyToManyField( differential = models.ManyToManyField(
Condition, through=Differential, related_name="casedifferential" Condition, through=Differential, related_name="casedifferential"
+15 -14
View File
@@ -4,7 +4,7 @@ from django_tables2.utils import A
from .models import ( from .models import (
Case, Case,
Condition, Condition,
PathalogicalProcess, PathologicalProcess,
Presentation, Presentation,
Series, Series,
Structure, Structure,
@@ -244,12 +244,12 @@ class PresentationTable(tables.Table):
verbose_name="Presentation", verbose_name="Presentation",
) )
#edit = tables.LinkColumn( # edit = tables.LinkColumn(
# "atlas:presentation_update", text="Edit", args=[A("pk")], orderable=False # "atlas:presentation_update", text="Edit", args=[A("pk")], orderable=False
#) # )
#delete = tables.LinkColumn( # delete = tables.LinkColumn(
# "atlas:presentation_delete", text="Delete", args=[A("pk")], orderable=False # "atlas:presentation_delete", text="Delete", args=[A("pk")], orderable=False
#) # )
selection = tables.CheckBoxColumn(accessor="pk", orderable=False) selection = tables.CheckBoxColumn(accessor="pk", orderable=False)
subspecialty = tables.ManyToManyColumn(verbose_name="Subspecialty") subspecialty = tables.ManyToManyColumn(verbose_name="Subspecialty")
@@ -267,32 +267,33 @@ class PathologicalProcessTable(tables.Table):
verbose_name="PathologicalProcess", verbose_name="PathologicalProcess",
) )
#edit = tables.LinkColumn( # edit = tables.LinkColumn(
# "atlas:pathological_process_update", text="Edit", args=[A("pk")], orderable=False # "atlas:pathological_process_update", text="Edit", args=[A("pk")], orderable=False
#) # )
#delete = tables.LinkColumn( # delete = tables.LinkColumn(
# "atlas:pathological_process_delete", text="Delete", args=[A("pk")], orderable=False # "atlas:pathological_process_delete", text="Delete", args=[A("pk")], orderable=False
#) # )
selection = tables.CheckBoxColumn(accessor="pk", orderable=False) selection = tables.CheckBoxColumn(accessor="pk", orderable=False)
class Meta: class Meta:
model = PathalogicalProcess model = PathologicalProcess
template_name = "django_tables2/bootstrap4.html" template_name = "django_tables2/bootstrap4.html"
fields = ("name",) fields = ("name",)
sequence = ("name",) sequence = ("name",)
class SubspecialtyTable(tables.Table): class SubspecialtyTable(tables.Table):
name = tables.Column( name = tables.Column(
linkify=("atlas:subspecialty_detail", {"pk": tables.A("pk")}), linkify=("atlas:subspecialty_detail", {"pk": tables.A("pk")}),
verbose_name="Subspecialty", verbose_name="Subspecialty",
) )
#edit = tables.LinkColumn( # edit = tables.LinkColumn(
# "atlas:subspecialty_update", text="Edit", args=[A("pk")], orderable=False # "atlas:subspecialty_update", text="Edit", args=[A("pk")], orderable=False
#) # )
#delete = tables.LinkColumn( # delete = tables.LinkColumn(
# "atlas:subspecialty_delete", text="Delete", args=[A("pk")], orderable=False # "atlas:subspecialty_delete", text="Delete", args=[A("pk")], orderable=False
#) # )
selection = tables.CheckBoxColumn(accessor="pk", orderable=False) selection = tables.CheckBoxColumn(accessor="pk", orderable=False)
class Meta: class Meta:
+3 -3
View File
@@ -40,7 +40,7 @@ from .forms import (
from .models import ( from .models import (
Case, Case,
Condition, Condition,
PathalogicalProcess, PathologicalProcess,
Presentation, Presentation,
Series, Series,
Examination, Examination,
@@ -210,7 +210,7 @@ def presentation_detail(request, pk):
@login_required @login_required
@user_is_atlas_checker @user_is_atlas_checker
def pathological_process_detail(request, pk): def pathological_process_detail(request, pk):
pathological_process = get_object_or_404(PathalogicalProcess, pk=pk) pathological_process = get_object_or_404(PathologicalProcess, pk=pk)
# logging.debug(atlas.subspecialty.first().name.all()) # logging.debug(atlas.subspecialty.first().name.all())
return render( return render(
@@ -685,7 +685,7 @@ class PresentationView(LoginRequiredMixin, SingleTableMixin, FilterView):
class PathologicalProcessView(LoginRequiredMixin, SingleTableMixin, FilterView): class PathologicalProcessView(LoginRequiredMixin, SingleTableMixin, FilterView):
model = PathalogicalProcess model = PathologicalProcess
table_class = PathologicalProcessTable table_class = PathologicalProcessTable
template_name = "atlas/view.html" template_name = "atlas/view.html"