.
This commit is contained in:
+7
-1
@@ -1,6 +1,6 @@
|
||||
import django_filters
|
||||
|
||||
from .models import Long
|
||||
from .models import Long, LongSeries
|
||||
|
||||
|
||||
class LongFilter(django_filters.FilterSet):
|
||||
@@ -8,3 +8,9 @@ class LongFilter(django_filters.FilterSet):
|
||||
model = Long
|
||||
fields = (#"site",
|
||||
"created_date", "author")
|
||||
|
||||
class LongSeriesFilter(django_filters.FilterSet):
|
||||
class Meta:
|
||||
model = LongSeries
|
||||
fields = (#"site",
|
||||
"created_date", "author")
|
||||
+33
-3
@@ -10,7 +10,7 @@ from easy_thumbnails.files import get_thumbnailer
|
||||
from easy_thumbnails.exceptions import InvalidImageFormatError
|
||||
|
||||
|
||||
class ImageColumn(tables.Column):
|
||||
class LongImageColumn(tables.Column):
|
||||
def render(self, value):
|
||||
obj = value.first()
|
||||
|
||||
@@ -26,6 +26,18 @@ class ImageColumn(tables.Column):
|
||||
#except InvalidImageFormatError:
|
||||
# return format_html('<span title="{}">Invalid image url<span>', image_object)
|
||||
|
||||
class LongSeriesImageColumn(tables.Column):
|
||||
def render(self, value):
|
||||
obj = value.first()
|
||||
|
||||
image_object = obj.image
|
||||
try:
|
||||
thumbnailer = get_thumbnailer(image_object)
|
||||
return format_html('<img src="/media/{}" />', thumbnailer["exam-list"])
|
||||
except InvalidImageFormatError:
|
||||
return format_html('<span title="{}">Invalid image url<span>', image_object)
|
||||
|
||||
|
||||
|
||||
class LongTable(tables.Table):
|
||||
edit = tables.LinkColumn('longs:long_update',
|
||||
@@ -40,11 +52,29 @@ class LongTable(tables.Table):
|
||||
text='Clone',
|
||||
args=[A('pk')],
|
||||
orderable=False)
|
||||
series = ImageColumn("images", orderable=False)
|
||||
series = LongImageColumn("Images", orderable=False)
|
||||
|
||||
class Meta:
|
||||
model = Long
|
||||
template_name = "django_tables2/bootstrap4.html"
|
||||
fields = ("normal", "abnormality", "region", "examination",
|
||||
"laterality", "site", "created_date", "author")
|
||||
sequence = ("view", "series")
|
||||
sequence = ("view", "series")
|
||||
|
||||
class LongSeriesTable(tables.Table):
|
||||
edit = tables.LinkColumn('longs:long_series_update',
|
||||
text='Edit',
|
||||
args=[A('pk')],
|
||||
orderable=False)
|
||||
view = tables.LinkColumn('longs:long_series_detail',
|
||||
text='View',
|
||||
args=[A('pk')],
|
||||
orderable=False)
|
||||
images = LongSeriesImageColumn("Images", orderable=False)
|
||||
|
||||
class Meta:
|
||||
model = Long
|
||||
template_name = "django_tables2/bootstrap4.html"
|
||||
fields = ("normal", "abnormality", "region", "examination",
|
||||
"laterality", "site", "created_date", "author")
|
||||
sequence = ("view", "images")
|
||||
@@ -18,7 +18,8 @@ Longs
|
||||
Longs:
|
||||
{% if request.user.is_authenticated %}
|
||||
<a href="{% url 'longs:exam_list' %}">Exams</a> /
|
||||
<a href="{% url 'longs:long_view' %}">Questions</a> /
|
||||
<a href="{% url 'longs:long_view' %}">Cases</a> /
|
||||
<a href="{% url 'longs:long_series_view' %}">Series</a> /
|
||||
<a href="{% url 'longs:long_create' %}" title="Create a new long case">Create Case</a> /
|
||||
<a href="{% url 'longs:long_series_create' %}" title="Create a new image series">Create Series</a>
|
||||
{% endif %}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
<p class="pre-whitespace"><b>History:</b> {{ question.history }}</p>
|
||||
|
||||
<p class="pre-whitespace"><b>Abnormality:</b> {{ question.get_abnormalities }}</p>
|
||||
<div class="pre-whitespace multi-image-block"><b>Series:</b>
|
||||
{% for series in question.series.all %}
|
||||
<span class="series-block">
|
||||
|
||||
@@ -9,6 +9,7 @@ urlpatterns = [
|
||||
path("author/<int:pk>/", views.author_detail, name="author_detail"),
|
||||
path("author/", views.author_list, name="author_list"),
|
||||
path("question/", views.LongView.as_view(), name="long_view"),
|
||||
path("series/", views.LongSeriesView.as_view(), name="long_series_view"),
|
||||
path("series/<int:pk>", views.long_series_detail, name="long_series_detail"),
|
||||
#path("unchecked/", views.unchecked_list, name="unchecked_list"),
|
||||
#path("verified/<int:pk>/", views.verified_detail, name="verified_detail"),
|
||||
|
||||
+9
-2
@@ -33,8 +33,8 @@ from .models import (
|
||||
Exam,
|
||||
CidUserAnswer,
|
||||
)
|
||||
from .tables import LongTable
|
||||
from .filters import LongFilter
|
||||
from .tables import LongTable, LongSeriesTable
|
||||
from .filters import LongFilter, LongSeriesFilter
|
||||
|
||||
from django_tables2 import SingleTableView, SingleTableMixin
|
||||
from django_filters.views import FilterView
|
||||
@@ -585,6 +585,13 @@ class LongView(SingleTableMixin, FilterView):
|
||||
|
||||
filterset_class = LongFilter
|
||||
|
||||
class LongSeriesView(SingleTableMixin, FilterView):
|
||||
model = LongSeries
|
||||
table_class = LongSeriesTable
|
||||
template_name = "longs/view.html"
|
||||
|
||||
filterset_class = LongSeriesFilter
|
||||
|
||||
|
||||
def loadJsonAnswer(answer):
|
||||
eid = int(answer["eid"].split("/")[1])
|
||||
|
||||
Reference in New Issue
Block a user