merge rapids commit
This commit is contained in:
Executable
+5
@@ -0,0 +1,5 @@
|
||||
{% extends "admin/base_site.html" %}
|
||||
{% load static %}
|
||||
{% block extrahead %}
|
||||
<link rel="stylesheet" href="{% static 'css/admin.css' %}">
|
||||
{% endblock %}
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
{% extends 'rapids/base.html' %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
{% for author in authors %}
|
||||
<p>Author: <a href="{% url 'rapids:author_detail' pk=author.pk %}">{{author.username}}</a>, </p>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
Executable
+54
@@ -0,0 +1,54 @@
|
||||
{% load static %}
|
||||
<html>
|
||||
|
||||
<head>
|
||||
|
||||
{% block css %}
|
||||
{% endblock %}
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="{% static 'tagulous/lib/select2-3/select2.css' %}">
|
||||
<link rel="stylesheet" href="{% static 'css/sbas.css' %}">
|
||||
|
||||
<script src="{% static 'tagulous/lib/jquery.js' %}"></script>
|
||||
<script src="{% static 'tagulous/lib/select2-3/select2.min.js' %}"></script>
|
||||
<script src="{% static 'tagulous/tagulous.js' %}"></script>
|
||||
<script src="{% static 'tagulous/adaptor/select2-3.js' %}"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="{% static 'js/dwv/i18next.min.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'js/dwv/dwv.min.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'js/dwv/appgui.js' %}"></script>
|
||||
{% block js %}
|
||||
{% endblock %}
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<title>Rapids</title>
|
||||
<div id=link-block>
|
||||
{% if request.user.is_staff %}<span id="admin-link"><a
|
||||
href="{% url 'admin:index' %}">Admin</a></span>{% endif %}
|
||||
<span id="view-link"><a href="{% url 'rapids:rapid_view' %}">View questions</a></span>
|
||||
<span id="create-link"><a href="{% url 'rapids:rapid_create' %}">Add new rapid</a></span>
|
||||
<span id="password-change-link"><a href="{% url 'password_change' %}">Change password</a></span>
|
||||
<span id="logout-link"><a href="{% url 'logout' %}">Logout</a></span>
|
||||
</br>
|
||||
Questions by:
|
||||
<span id="authors-link"><a href="{% url 'rapids:author_list' %}">author</a></span>
|
||||
</div>
|
||||
|
||||
<div class="page-header">
|
||||
<h1>Rapids</h1>
|
||||
</div>
|
||||
<div class="content container">
|
||||
{% block navigation %}
|
||||
{% endblock %}
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
{% block content %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
{% extends 'rapids/base.html' %}
|
||||
|
||||
{% block content %}
|
||||
{{category}}:
|
||||
<ul>
|
||||
{% for rapid in rapids %}
|
||||
<li><a href="{% url 'rapids:rapid_detail' pk=rapid.pk %}">{{rapid}}
|
||||
[{{rapid.get_authors}}]</a></li>
|
||||
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
{% endblock %}
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
<h2>Add new {{name}}</h2>
|
||||
<form method="POST" class="post-form">{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<button type="submit" class="save btn btn-default">Save</button>
|
||||
</form>
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
{% extends 'rapids/base.html' %}
|
||||
|
||||
{% block content %}
|
||||
My Questions:
|
||||
<ul>
|
||||
{% for rapid in user_rapids %}
|
||||
<li{% if rapid.scrapped %} class='rapid-scrapped' {% endif %}><a
|
||||
href="{% url 'rapids:rapid_detail' pk=rapid.pk %}">{{rapid}}
|
||||
[{{rapid.get_authors}}]</a></li>
|
||||
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
Other Questions:
|
||||
<ul>
|
||||
{% for rapid in other_rapids %}
|
||||
<li{% if rapid.scrapped %} class='rapid-scrapped' {% endif %}><a
|
||||
href="{% url 'rapids:rapid_detail' pk=rapid.pk %}">{{rapid}} [{{rapid.get_authors}}]</a></li>
|
||||
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
{% endblock %}
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
{% extends "rapids/base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<h2>Add Note</h2>
|
||||
<form action="" method="post">
|
||||
{% csrf_token %}
|
||||
<table>
|
||||
{{ form.as_table }}
|
||||
</table>
|
||||
<input type="submit" value="Submit">
|
||||
</form>
|
||||
{% endblock %}
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
{% extends 'rapids/base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<a href="{% url 'rapids:rapid_update' pk=rapid.pk %}" title="Edit the Rapid">Edit</a>
|
||||
<a href="{% url 'rapids:rapid_clone' pk=rapid.pk %}" title="Clone the Rapid (duplicate everything but the images)">Clone</a>
|
||||
<a href="{% url 'rapids:rapid_add_note' pk=rapid.pk %}"> Add Note</a>
|
||||
{% if request.user.is_superuser %}
|
||||
<a href="{% url 'admin:rapids_rapid_change' rapid.id %}" title="Edit the Rapid using the admin interface">Admin Edit</a>
|
||||
{% endif %}
|
||||
{% include 'rapids/rapid_display_block.html' %}
|
||||
{% endblock %}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
<div class="rapid {% if rapid.scrapped %}rapid-scrapped{% endif %}">
|
||||
<div class="date">
|
||||
{{ rapid.created_date }}
|
||||
</div>
|
||||
|
||||
<p class="pre-whitespace"><b>Rapid:</b> {{ rapid }}</p>
|
||||
<p class="pre-whitespace"><b>Region:</b> {{ rapid.get_regions }}</p>
|
||||
<p class="pre-whitespace"><b>Abnormality:</b> {{ rapid.get_abnormalities }}</p>
|
||||
<p class="pre-whitespace"><b>Images:</b>
|
||||
{% for image in rapid.images.all %}
|
||||
Image {{ forloop.counter }}{% if image.feedback_image %} [feedback image]{% endif %}:
|
||||
<img class="rapid-img {% if image.feedback_image %}feedback-img{% endif %}" src="{{ image.image.url }}">
|
||||
{% endfor %}</p>
|
||||
<p class="pre-whitespace"><b>Feedback:</b> {{ rapid.feedback }}</p>
|
||||
<p><b>Author(s):</b> {% for author in rapid.author.all %} <a
|
||||
href="{% url 'rapids:author_detail' pk=author.pk %}">{{author}}</a>, {% endfor %}</p>
|
||||
<p><b>Checked by:</b> {% for verified in rapid.verified.all %} <a
|
||||
href="{% url 'rapids:verified_detail' pk=verified.pk %}">{{verified}}</a>, {% endfor %}</p>
|
||||
<p><b>Scrapped:</b> {{ rapid.scrapped }} <a href="{% url 'rapids:rapid_scrap' pk=rapid.pk %}">(toggle)</a>
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
Notes:
|
||||
<ul>
|
||||
{% for note in rapid.rapid_notes.all %}
|
||||
<li>
|
||||
{{ note.created_on }} by {{ note.author }}: {{ note.note }}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
Executable
+251
@@ -0,0 +1,251 @@
|
||||
{% extends "rapids/base.html" %}
|
||||
{% load static from staticfiles %}
|
||||
|
||||
{% block js %}
|
||||
<!--<script type="text/javascript" src="/admin/jsi18n/"></script>-->
|
||||
|
||||
<script type="text/javascript">
|
||||
function showEditPopup(url) {
|
||||
var win = window.open(url, "Edit",
|
||||
'height=500,width=800,resizable=yes,scrollbars=yes');
|
||||
return false;
|
||||
}
|
||||
function showAddPopup(triggeringLink) {
|
||||
var name = triggeringLink.id.replace(/^add_/, '');
|
||||
href = triggeringLink.href;
|
||||
var win = window.open(href, name, 'height=500,width=800,resizable=yes,scrollbars=yes');
|
||||
win.focus();
|
||||
return false;
|
||||
}
|
||||
function closePopup(win, newID, newRepr, id) {
|
||||
console.log(id)
|
||||
$(id + "_to").append('<option value=' + newID + ' title=' + newRepr + ' >' + newRepr + '</option>')
|
||||
win.close();
|
||||
}
|
||||
|
||||
document.addEventListener('drop', function (e) { e.preventDefault(); }, false);
|
||||
|
||||
function add_input_form() {
|
||||
var form_idx = $('#id_images-TOTAL_FORMS').val();
|
||||
$('#form_set').append($('#empty_form').html().replace(/__prefix__/g, form_idx));
|
||||
$('#id_images-TOTAL_FORMS').val(parseInt(form_idx) + 1);
|
||||
}
|
||||
|
||||
|
||||
$(document).ready(function () {
|
||||
$("#add_abnormality").appendTo($("label[for='id_abnormality']"));
|
||||
$("#add_examination").appendTo($("label[for='id_examination']"));
|
||||
$("#add_region").appendTo($("label[for='id_region']"));
|
||||
|
||||
dropContainer = document.getElementById("drop-container");
|
||||
|
||||
dropContainer.ondragover = function (evt) {
|
||||
evt.preventDefault();
|
||||
evt.stopPropagation();
|
||||
};
|
||||
|
||||
dropContainer.ondragenter = function (evt) {
|
||||
console.log("ENTER")
|
||||
console.log(evt)
|
||||
$(evt.target).addClass("drop-target-active")
|
||||
evt.preventDefault();
|
||||
evt.stopPropagation();
|
||||
};
|
||||
|
||||
dropContainer.ondragleave = function (evt) {
|
||||
console.log("ENTER")
|
||||
console.log(evt)
|
||||
$(evt.target).removeClass("drop-target-active")
|
||||
evt.preventDefault();
|
||||
evt.stopPropagation();
|
||||
};
|
||||
|
||||
dropContainer.ondrop = function (evt) {
|
||||
console.log("SHIT", evt);
|
||||
$(evt.target).removeClass("drop-target-active");
|
||||
|
||||
// Get all input elements
|
||||
inputs = $("#rapid-form input[type=file][id^=id_images-]");
|
||||
//fileInput = document.getElementById("id_images-0-image");
|
||||
|
||||
// Make sure we have enough input targets
|
||||
input_diff = (evt.dataTransfer.files.length - inputs.length)
|
||||
console.log("diff", input_diff)
|
||||
|
||||
if(input_diff > 0) {
|
||||
for(let j = 0; j < input_diff; j++) {
|
||||
add_input_form()
|
||||
}
|
||||
|
||||
// Need to make sure we include the new ones...
|
||||
inputs = $("#rapid-form input[type=file][id^=id_images-]");
|
||||
}
|
||||
|
||||
// Loop through each dropped file and try to assign to an
|
||||
// input element
|
||||
[...evt.dataTransfer.files].forEach((f) => {
|
||||
let dT = new DataTransfer();
|
||||
dT.clearData();
|
||||
dT.items.add(f);
|
||||
for(let i = 0; i < inputs.length; i++) {
|
||||
el = inputs.get(i)
|
||||
|
||||
if(el.files.length == 0) {
|
||||
el.files = dT.files;
|
||||
ocr(el)
|
||||
|
||||
if(evt.target.id == "feedback-drop-target") {
|
||||
arr = el.name.split("-");
|
||||
arr.splice(2, 1, "feedback_image");
|
||||
feedback_el_name = arr.join("-");
|
||||
|
||||
$(`[name=${feedback_el_name}]`).prop("checked", true);
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// // If you want to use some of the dropped files
|
||||
// const dT = new DataTransfer();
|
||||
// dT.items.add(evt.dataTransfer.files[0]);
|
||||
// dT.items.add(evt.dataTransfer.files[3]);
|
||||
// fileInput.files = dT.files;
|
||||
|
||||
evt.preventDefault();
|
||||
evt.stopPropagation();
|
||||
updateFileList();
|
||||
};
|
||||
|
||||
|
||||
$('#add_more').click(() => { add_input_form() });
|
||||
|
||||
function updateFileList() {
|
||||
$("#drop-filenames").empty()
|
||||
$("#form_set input[type=file]").each((n, el) => {
|
||||
console.log(el);
|
||||
if(el.files.length > 0) {
|
||||
extra_class = " image-ident-loading";
|
||||
if($(el).hasClass("image-ident-warning")) {
|
||||
extra_class = " image-ident-warning"
|
||||
} else if($(el).hasClass("image-ident-ok")) {
|
||||
extra_class = " image-ident-ok"
|
||||
}
|
||||
$("#drop-filenames").append(
|
||||
`<span>${n}: ${el.files[0].name}</span><img class='uploading${extra_class}' data-input-id='${el.id}' src=${URL.createObjectURL(el.files[0])}>`
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
$("input[type=file]").on('change', function () {
|
||||
$(this).removeClass("image-ident-warning");
|
||||
$(this).removeClass("image-ident-ok");
|
||||
updateFileList();
|
||||
console.log("input change1");
|
||||
console.log("input change", this);
|
||||
ocr(this);
|
||||
});
|
||||
|
||||
});
|
||||
function ocr(input) {
|
||||
// Tesseract.recognize(f, "eng",{ logger: m => console.log(m) }
|
||||
// ).then(({ data: { text } }) => {
|
||||
// console.log(text);
|
||||
// l = text.toLowerCase();
|
||||
// if (l.includes("accesion") || l.includes("number") || l.search(/(REF|RK9|RH8|RA9)\d+/g)) {
|
||||
// console.log("SHIT", this);
|
||||
// }
|
||||
// })
|
||||
|
||||
console.log('{% static "worker.min.js" %}');
|
||||
console.log('{{ STATIC_URL }}/tesseract-core.wasm.js %}');
|
||||
|
||||
const worker = Tesseract.createWorker({
|
||||
workerPath: '{% static "worker.min.js" %}',
|
||||
langPath: '{% static "" %}',
|
||||
//langPath: '{{ STATIC_URL }}',
|
||||
corePath: '{% static "tesseract-core.wasm.js" %}',
|
||||
});
|
||||
|
||||
const url = URL.createObjectURL(input.files[0]);
|
||||
let img = new Image;
|
||||
img.src = url;
|
||||
|
||||
img.onload = function () {
|
||||
|
||||
|
||||
width = img.width;
|
||||
|
||||
// const rectangle = { left: 0, top: 0, width: width, height: 10 }
|
||||
|
||||
|
||||
(async () => {
|
||||
await worker.load();
|
||||
await worker.loadLanguage('eng');
|
||||
await worker.initialize('eng');
|
||||
// const { data: { text } } = await worker.recognize(input.files[0], { rectangle });
|
||||
const { data: { text } } = await worker.recognize(input.files[0]);
|
||||
//console.log(text);
|
||||
l = text.toLowerCase();
|
||||
$(`img[data-input-id='${input.id}'`).removeClass("image-ident-loading");
|
||||
console.log(l);
|
||||
if(l.includes("accesion") || l.includes("number") || l.search(/(ref|rk9|rh8|ra9|rbz)\d+/g) > -1) {
|
||||
console.log("SHIT", input);
|
||||
$(input).addClass("image-ident-warning");
|
||||
$(`img[data-input-id='${input.id}'`).addClass("image-ident-warning");
|
||||
} else {
|
||||
$(input).addClass("image-ident-ok");
|
||||
|
||||
}
|
||||
|
||||
await worker.terminate();
|
||||
})();
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
{{ form.media }}
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<h2>Submit Rapid</h2>
|
||||
<a href="{% url 'rapids:rapid_create_defaults' %}">Edit defaults</a>
|
||||
<form action="" method="post" enctype="multipart/form-data" id="rapid-form">
|
||||
{% csrf_token %}
|
||||
<a href="/rapids/abnormality/create" id="add_abnormality" class="add-popup"
|
||||
onclick="return showAddPopup(this);"><img src="{% static '/img/icon-addlink.svg' %}"></a>
|
||||
<a href="/rapids/examination/create" id="add_examination" class="add-popup"
|
||||
onclick="return showAddPopup(this);"><img src="{% static '/img/icon-addlink.svg' %}"></a>
|
||||
<a href="/rapids/region/create" id="add_region" class="add-popup" onclick="return showAddPopup(this);"><img
|
||||
src="{% static '/img/icon-addlink.svg' %}"></a>
|
||||
|
||||
<table>
|
||||
{{ form.as_table }}
|
||||
</table>
|
||||
<h3>Images:</h3>
|
||||
<input type="button" value="Add More Images" id="add_more">
|
||||
<div id="drop-container" class="drop-target">Drop images here (or use the buttons below)<div
|
||||
id="feedback-drop-target">Feedback image?<br />drop those here</div>
|
||||
<div id="drop-filenames"></div>
|
||||
</div>
|
||||
<div id="form_set">
|
||||
{% for form in image_formset %}
|
||||
<ul class="no-error image-formset">
|
||||
{{form.non_field_errors}}
|
||||
{{form.errors}}
|
||||
{{ form.as_ul }}
|
||||
</ul>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{{ image_formset.management_form }}
|
||||
<input type="submit" class="submit-button" value="Submit" name="submit">
|
||||
<input type="submit" class="submit-button" value="Submit and Clone" name="submit-clone">
|
||||
</form>
|
||||
<div id="empty_form" style="display:none">
|
||||
<ul class='no_error image-formset'>
|
||||
{{ image_formset.empty_form.as_ul }}
|
||||
</ul>
|
||||
</div>
|
||||
{% endblock %}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
{% extends "rapids/base.html" %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
<h2>Defaults for creating new rapids</h2>
|
||||
<form method="POST" class="post-form">{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<button type="submit" class="save btn btn-primary">Save</button>
|
||||
</form>
|
||||
{% endblock %}
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
{% extends 'rapids/base.html' %}
|
||||
|
||||
{% load render_table from django_tables2 %}
|
||||
{% block css %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div id="view-filter-options">
|
||||
<h3>Filter Rapids</h3>
|
||||
<form action="" method="get">
|
||||
{{ filter.form }}
|
||||
<input class="btn btn-primary btn-sm mt-1 mb-1" type="submit" />
|
||||
</form>
|
||||
</div>
|
||||
{% render_table table %}
|
||||
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user