Skip to content

Commit 29bbc78

Browse files
authored
Merge pull request #1536 from ImagingDataCommons/release-50-sp
#1525 bugfixes
2 parents cddf8eb + 4095dba commit 29bbc78

5 files changed

Lines changed: 28 additions & 10 deletions

File tree

idc/models.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,22 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16+
import uuid
17+
from datetime import timedelta
1618

1719
from django.db import models
1820
from django.contrib.auth.models import User
19-
21+
import uuid
22+
import datetime
23+
import base64
2024
import logging
2125

2226
logger = logging.getLogger(__name__)
2327

28+
def cart_keygen():
29+
return '{}'.format(base64.b64encode(uuid.uuid4().bytes).replace("=",""))
30+
31+
CART_EXPIRATION = datetime.timedelta(days=90)
2432

2533
class AppInfo(models.Model):
2634
id = models.AutoField(primary_key=True, null=False, blank=False)
@@ -29,9 +37,7 @@ class AppInfo(models.Model):
2937
app_date = models.DateField(auto_now_add=True, null=False, blank=False)
3038
active = models.BooleanField(default=True, null=False, blank=False)
3139

32-
3340
class User_Data(models.Model):
3441
id = models.AutoField(primary_key=True, null=False, blank=False)
3542
user = models.ForeignKey(User, null=False, blank=True, on_delete=models.CASCADE)
3643
history = models.CharField(max_length=2000, blank=False, null=False, default='')
37-

idc/views.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959

6060
BQ_ATTEMPT_MAX = 10
6161
WEBAPP_LOGIN_LOG_NAME = settings.WEBAPP_LOGIN_LOG_NAME
62+
SERIES_COLLEX_ID_TYPE = {
63+
"collection": "collection_id",
64+
"analysis_result": "analysis_results_id"
65+
}
6266

6367

6468
# The site's homepage
@@ -617,12 +621,13 @@ def cart_data(request):
617621
def get_series(request, collection_id=None, patient_id=None, study_uid=None):
618622
status = 200
619623
response = {"result": []}
624+
req = request.GET if request.method == 'GET' else request.POST
620625
try:
621626
fields = ["collection_id", "PatientID", "StudyInstanceUID", "Modality", "crdc_series_uuid", "SeriesInstanceUID", "aws_bucket", "instance_size"]
622627
result = {}
623628
if not collection_id:
624629
# This is a request for filters and/or a cart
625-
body_unicode = request.body.decode('utf-8')
630+
body_unicode = req.body.decode('utf-8')
626631
body = json.loads(body_unicode)
627632
partitions = body.get("partitions", {})
628633
filtergrp_list = body.get("filtergrp_list", {})
@@ -656,8 +661,9 @@ def get_series(request, collection_id=None, patient_id=None, study_uid=None):
656661
active=True, source_type=DataSource.SOLR,
657662
aggregate_level="SeriesInstanceUID"
658663
).first()
664+
id_type = SERIES_COLLEX_ID_TYPE[req.get("type","collection")]
659665
filters = {
660-
"collection_id": [collection_id]
666+
id_type: [collection_id]
661667
}
662668
if patient_id:
663669
filters['PatientID'] = [patient_id]

static/js/downloader.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,8 @@ require([
954954
} else {
955955
let study_uri = (study_id !== undefined && study_id !== null) ? `${study_id}/` : "";
956956
let patient_uri = (patient_id !== undefined && patient_id !== null) ? `${patient_id}/` : "";
957-
response = await fetch(`${BASE_URL}${SERIES_IDS_URL}${collection_id}/${patient_uri}${study_uri}`);
957+
let type = (download_type === "analysis_result") ? `?type=analysis_result` : "";
958+
response = await fetch(`${BASE_URL}${SERIES_IDS_URL}${collection_id}/${patient_uri}${study_uri}${type}`);
958959
}
959960
if (!response.ok) {
960961
console.error(`[ERROR] Failed to retrieve series IDs: ${response.status}`);

static/js/tooltips.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,9 @@ require([
275275

276276
const manifest_tooltip = {
277277
dynamicTip: function(ref){
278+
if($(ref).hasClass('idc-index')) {
279+
return `View instructions for downloading this ${$(ref).attr("data-download-type-display")} using the idc-index tool.`;
280+
}
278281
let table_type = $(ref).parents('table').attr('data-table-type');
279282
if(table_type === 'series') {
280283
return 'Download a manifest file for this series to use with a download tool.'
@@ -304,7 +307,7 @@ require([
304307
return disabled_messages[$(ref).attr('data-disabled-type')];
305308
}
306309
let download_type = $(ref).attr('data-download-type');
307-
return `Download all of the files in this ${download_type}.`;
310+
return `Download all of the files in this ${download_type.replace("_"," ")}.`;
308311
},
309312
content: 'Download all files.', // placeholder text
310313
theme: 'dark',
@@ -354,7 +357,7 @@ require([
354357
tippy.delegate('.cases-table', copy_tip);
355358

356359
tippy.delegate('#body', {
357-
content: 'Get the citation list for this cohort.',
360+
content: 'View citation(s) in Vancouver Elsevier format.',
358361
theme: 'dark',
359362
placement: 'left',
360363
arrow: false,
@@ -403,6 +406,7 @@ require([
403406

404407
tippy.delegate('#body', disabled_download_tooltip);
405408
tippy.delegate('#body', download_tooltip);
409+
tippy.delegate("#collection_details", manifest_tooltip);
406410

407411
tippy.delegate('#body', {
408412
content: function(reference) {

templates/collections/collection_details.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,16 @@ <h3>{{ collection_type }} <i class="fa fa-solid fa-ellipsis-v collection-spacer"
3030
{% with size_warning=total_size_with_ar|size_check %}
3131
<li class="collex-list-item">
3232
<a class="dropdown-item download-instances{% if size_warning %} download-size-warning{% elif total_size_with_ar > 3 %} is-disabled{% else %} download-all-instances{% endif %}"
33-
href="#" data-download-type="collection" data-collection="{{ collection_id }}"{% if total_size_with_ar > 3 %}data-disabled-type="download-size-disabled"{% endif %}
33+
href="#" data-download-type="{{ collection_type.lower|replace_whitespace:"_" }}" data-collection="{{ collection_id }}"{% if total_size_with_ar > 3 %}data-disabled-type="download-size-disabled"{% endif %}
3434
{% if size_warning %}data-toggle="modal" data-target="#download-warning"{% endif %}
3535
>
3636
Direct <i class="fa fa-solid fa-download"></i></a></li>
3737
<li class="collex-list-item">
3838
<a
39-
class="dropdown-item"
39+
class="dropdown-item idc-index export-button"
4040
role="button"
4141
data-toggle="modal"
42+
data-download-type-display="{{ collection_type.lower }}"
4243
data-bs-toggle="modal"
4344
data-bs-target="#export-collex-manifest-modal"
4445
data-target="#export-collex-manifest-modal">idc-index <i class="fa fa-solid fa-list"></i>

0 commit comments

Comments
 (0)