clone rapids app into longs
This commit is contained in:
Executable
+48
@@ -0,0 +1,48 @@
|
||||
import django_tables2 as tables
|
||||
from django_tables2.utils import A
|
||||
|
||||
from .models import Rapid
|
||||
|
||||
from django.utils.html import format_html
|
||||
|
||||
from easy_thumbnails.files import get_thumbnailer
|
||||
|
||||
from easy_thumbnails.exceptions import InvalidImageFormatError
|
||||
|
||||
|
||||
class ImageColumn(tables.Column):
|
||||
def render(self, value):
|
||||
obj = value.first()
|
||||
|
||||
if obj is None:
|
||||
return format_html('<span>No image<span>')
|
||||
|
||||
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 RapidTable(tables.Table):
|
||||
edit = tables.LinkColumn('rapids:rapid_update',
|
||||
text='Edit',
|
||||
args=[A('pk')],
|
||||
orderable=False)
|
||||
view = tables.LinkColumn('rapids:rapid_detail',
|
||||
text='View',
|
||||
args=[A('pk')],
|
||||
orderable=False)
|
||||
clone = tables.LinkColumn('rapids:rapid_clone',
|
||||
text='Clone',
|
||||
args=[A('pk')],
|
||||
orderable=False)
|
||||
images = ImageColumn("images", orderable=False)
|
||||
|
||||
class Meta:
|
||||
model = Rapid
|
||||
template_name = "django_tables2/bootstrap4.html"
|
||||
fields = ("normal", "abnormality", "region", "examination",
|
||||
"laterality", "site", "created_date", "author")
|
||||
sequence = ("view", "images")
|
||||
Reference in New Issue
Block a user