From 1e8697e6bb7341e4469cea0059fb0ef0cfade83a Mon Sep 17 00:00:00 2001 From: Ross Date: Tue, 16 Feb 2021 11:05:45 +0000 Subject: [PATCH] . --- anatomy/static/css/anatomy.css | 4 ++++ longs/admin.py | 2 +- longs/forms.py | 2 +- longs/migrations/0020_auto_20210216_1018.py | 22 +++++++++++++++++++ longs/migrations/0021_auto_20210216_1018.py | 18 +++++++++++++++ longs/migrations/0022_long_mark_scheme.py | 18 +++++++++++++++ longs/models.py | 11 +++++----- longs/templates/longs/long_form.html | 17 +++++++++++--- longs/templates/longs/long_series_viewer.html | 5 ++++- longs/templates/longs/longseries_form.html | 13 ++++++++--- .../templates/physics/question_detail.html | 1 - templates/base.html | 17 +++++++++----- 12 files changed, 109 insertions(+), 21 deletions(-) create mode 100644 longs/migrations/0020_auto_20210216_1018.py create mode 100644 longs/migrations/0021_auto_20210216_1018.py create mode 100644 longs/migrations/0022_long_mark_scheme.py diff --git a/anatomy/static/css/anatomy.css b/anatomy/static/css/anatomy.css index 6fc7be38..ab2f6c02 100644 --- a/anatomy/static/css/anatomy.css +++ b/anatomy/static/css/anatomy.css @@ -454,4 +454,8 @@ td.user-answer-score-2::after { .sortable-placeholder { border: 4px solid purple; + } + + .temp-thumb { + float:right; } \ No newline at end of file diff --git a/longs/admin.py b/longs/admin.py index 2b2eb742..e340efa4 100755 --- a/longs/admin.py +++ b/longs/admin.py @@ -23,7 +23,7 @@ admin.site.register(LongSeriesImage) class LongImageInline(admin.TabularInline): - model = LongSeries + model = LongSeries.long.through extra = 1 diff --git a/longs/forms.py b/longs/forms.py index 0a2cc793..bcb5ff52 100755 --- a/longs/forms.py +++ b/longs/forms.py @@ -173,7 +173,7 @@ class LongForm(ModelForm): SeriesFormSet = inlineformset_factory( Long, - LongSeries, + LongSeries.long.through, exclude=[], can_delete=True, extra=1, diff --git a/longs/migrations/0020_auto_20210216_1018.py b/longs/migrations/0020_auto_20210216_1018.py new file mode 100644 index 00000000..61062655 --- /dev/null +++ b/longs/migrations/0020_auto_20210216_1018.py @@ -0,0 +1,22 @@ +# Generated by Django 3.1.3 on 2021-02-16 10:18 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('longs', '0019_longseriesimage_upload_filename'), + ] + + operations = [ + migrations.RemoveField( + model_name='longseries', + name='long', + ), + migrations.AddField( + model_name='longseries', + name='long', + field=models.ManyToManyField(blank=True, help_text='The question(s) this series should be associated with', null=True, related_name='series', to='longs.Long'), + ), + ] diff --git a/longs/migrations/0021_auto_20210216_1018.py b/longs/migrations/0021_auto_20210216_1018.py new file mode 100644 index 00000000..fd938849 --- /dev/null +++ b/longs/migrations/0021_auto_20210216_1018.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.3 on 2021-02-16 10:18 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('longs', '0020_auto_20210216_1018'), + ] + + operations = [ + migrations.AlterField( + model_name='longseries', + name='long', + field=models.ManyToManyField(blank=True, help_text='The question(s) this series should be associated with', related_name='series', to='longs.Long'), + ), + ] diff --git a/longs/migrations/0022_long_mark_scheme.py b/longs/migrations/0022_long_mark_scheme.py new file mode 100644 index 00000000..8ede2832 --- /dev/null +++ b/longs/migrations/0022_long_mark_scheme.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.3 on 2021-02-16 11:03 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('longs', '0021_auto_20210216_1018'), + ] + + operations = [ + migrations.AddField( + model_name='long', + name='mark_scheme', + field=models.TextField(blank=True, null=True), + ), + ] diff --git a/longs/models.py b/longs/models.py index 1b2d62a7..967356b2 100644 --- a/longs/models.py +++ b/longs/models.py @@ -79,6 +79,8 @@ class Long(models.Model): model_differential_diagnosis = models.TextField(null=True, blank=True) model_management = models.TextField(null=True, blank=True) + mark_scheme = models.TextField(null=True, blank=True) + DEFAULT_SITE_ID = 1 # site = models.ManyToManyField( # Site, @@ -171,12 +173,10 @@ class LongSeries(models.Model): on_delete=models.SET_NULL, null=True, ) - long = models.ForeignKey( + long = models.ManyToManyField( "Long", - help_text="The question this series should be associated with", + help_text="The question(s) this series should be associated with", related_name="series", - on_delete=models.SET_NULL, - null=True, blank=True, ) description = models.TextField( @@ -193,7 +193,8 @@ class LongSeries(models.Model): def __str__(self): if self.long: - long_id = self.long.pk + long_id = ", ".format([long.pk for long in self.long.all()]) + #long_id = self.long.pk else: long_id = "None" return "{} : {} [{}]".format( diff --git a/longs/templates/longs/long_form.html b/longs/templates/longs/long_form.html index 8f13fd17..b3fb7f34 100755 --- a/longs/templates/longs/long_form.html +++ b/longs/templates/longs/long_form.html @@ -1,5 +1,5 @@ {% extends "longs/base.html" %} -{% load static from static %} + {% block js %} @@ -24,13 +24,23 @@ } + function add_input_form() { + var form_idx = $('#id_LongSeries_long-TOTAL_FORMS').val(); + $('#form_set').append($('#empty_form').html().replace(/__prefix__/g, form_idx)); + $('#id_LongSeries_long-TOTAL_FORMS').val(parseInt(form_idx) + 1); + } + + $(document).ready(function () { + $('#add_more').click(() => { add_input_form() }); + }) + -{{ form.media }} + {% endblock %} {% block content %}

Submit Long Case

-Use this form to create a long case. Associated image sets can be added using this form however the images will have to be uploaded once the case has been created. +Use this form to create a long case. Existing associated image sets can be added using this form.
{% csrf_token %} @@ -38,6 +48,7 @@ Use this form to create a long case. Associated image sets can be added using th {{ form.as_table }}

Series:

+ Add image sets here. These can only be added once created (they can also be added to cases on creation).
{% for form in series_formset %} diff --git a/longs/templates/longs/long_series_viewer.html b/longs/templates/longs/long_series_viewer.html index 72844e73..c31c5c53 100755 --- a/longs/templates/longs/long_series_viewer.html +++ b/longs/templates/longs/long_series_viewer.html @@ -2,7 +2,10 @@
{{ series.modality}}, {{ series.examination }}
{% if series.long %} -Associated case: {{series.long}} +Associated case: +{% for long in series.long.all %} +{{long}} +{% endfor %} {% else %} This series is not associated with any cases. {% endif %} diff --git a/longs/templates/longs/longseries_form.html b/longs/templates/longs/longseries_form.html index ae17aaf9..6ac2f305 100755 --- a/longs/templates/longs/longseries_form.html +++ b/longs/templates/longs/longseries_form.html @@ -1,5 +1,4 @@ {% extends "longs/base.html" %} -{% load static from static %} {% block js %} @@ -131,7 +130,7 @@ sortable('.sortable'); - sortable('.sortable')[0].addEventListener('sortstop', function(e) { + sortable('.sortable')[0].addEventListener('sortupdate', function(e) { /* This event is triggered when the user stops sorting and the DOM position has not yet changed. @@ -143,7 +142,10 @@ e.detail.origin.elementIndex - {Integer} Index of the element in all elements in the Sortable Container e.detail.origin.container - {HTMLElement} Sortable Container that element was moved out of (or copied from) */ - updateImagePositions(); + //updateImagePositions(); + + $(".temp-thumb").remove() + loadDicomViewer(); }); }); @@ -207,6 +209,7 @@ async function loadDicomViewer(callback) { + $("#single-dicom-viewer").empty() //images = [] //Function that returns a promise to read the file const reader = (file) => { @@ -223,6 +226,7 @@ image.height = 100; image.title = file.name; image.src = reader.result; + image.className = "temp-thumb"; console.log("read" ,el); $(el).parent().parent().prepend(image); //images.push(reader.result); @@ -235,6 +239,7 @@ file_set = $("#image_form_set input[type=file]"); + file_set.each(async (n, el) => { console.log(el); if (el.files.length > 0) { @@ -266,6 +271,8 @@ const event = new CustomEvent('loadDicomViewer', { "detail": image_set }); window.dispatchEvent(event); + sortable('.sortable'); + //sortable('.sortable')[0].addEventListener('sortstop', function(e) { updateImagePositions(); } diff --git a/physics/templates/physics/question_detail.html b/physics/templates/physics/question_detail.html index a626b5ab..f3c7d1eb 100644 --- a/physics/templates/physics/question_detail.html +++ b/physics/templates/physics/question_detail.html @@ -1,7 +1,6 @@ {% extends 'physics/base.html' %} {% block content %} -{% load static %}
Admin Edit
diff --git a/templates/base.html b/templates/base.html index 8aa430c7..e10929a7 100644 --- a/templates/base.html +++ b/templates/base.html @@ -10,21 +10,26 @@ {% block css %} {% endblock %} + + - - - - + + + + - - + + + + +