From dbdf650a860a39d03bbb252e37e406bae63f6494 Mon Sep 17 00:00:00 2001 From: Dan LaManna Date: Mon, 25 Nov 2024 16:46:57 -0500 Subject: [PATCH 1/2] Remove locked from collection detail page --- isic/core/templates/core/collection_detail.html | 4 ---- 1 file changed, 4 deletions(-) diff --git a/isic/core/templates/core/collection_detail.html b/isic/core/templates/core/collection_detail.html index 687c52c1..e3c2be44 100644 --- a/isic/core/templates/core/collection_detail.html +++ b/isic/core/templates/core/collection_detail.html @@ -106,10 +106,6 @@ {% endif %} {% endif %} -
  • - Locked: - {{ collection.locked|yesno }} -
  • {% if collection.description %} From c9cc52ef8e0e95aef4829ba21380927ede6c26ee Mon Sep 17 00:00:00 2001 From: Dan LaManna Date: Mon, 25 Nov 2024 18:13:37 -0500 Subject: [PATCH 2/2] Emphasize private collection attributes --- isic/core/api/collection.py | 29 +-- .../templates/core/collection_detail.html | 195 ++++++++++-------- isic/core/tests/test_api_collection.py | 1 + .../ingest/partials/cohort_details.html | 2 +- .../studies/partials/study_details.html | 2 +- node-src/styles.pcss | 4 + 6 files changed, 126 insertions(+), 107 deletions(-) diff --git a/isic/core/api/collection.py b/isic/core/api/collection.py index 52964358..5a87056d 100644 --- a/isic/core/api/collection.py +++ b/isic/core/api/collection.py @@ -1,7 +1,7 @@ from typing import Literal from django.contrib import messages -from django.db.models import Count, Q +from django.db.models import Count from django.http.response import JsonResponse from django.shortcuts import get_object_or_404 from jaro import jaro_winkler_metric @@ -11,7 +11,6 @@ from pydantic.types import conlist, constr from isic.core.constants import ISIC_ID_REGEX -from isic.core.models.base import CopyrightLicense from isic.core.models.collection import Collection from isic.core.pagination import CursorPagination from isic.core.permissions import get_visible_objects @@ -136,32 +135,24 @@ def collection_share_to_users(request, id: int, payload: CollectionShareIn): return 202, {} -class CollectionLicenseBreakdown(Schema): - license_counts: dict[str, int] - - @router.get( - "/{id}/licenses/", - response=CollectionLicenseBreakdown, - summary="Retrieve a breakdown of the licenses of the specified collection.", + "/{id}/attribution/", + summary="Retrieve attribution information of the specified collection.", include_in_schema=False, ) -def collection_license_breakdown(request, id: int) -> dict[str, int]: +def collection_attribution_information(request, id: int) -> list[dict[str, int]]: qs = get_visible_objects(request.user, "core.view_collection") collection = get_object_or_404(qs, id=id) images = get_visible_objects(request.user, "core.view_image", collection.images.distinct()) - license_counts = ( + counts = ( Accession.objects.filter(image__in=images) - .values("copyright_license") - .aggregate( - **{ - license_: Count("copyright_license", filter=Q(copyright_license=license_)) - for license_ in CopyrightLicense.values - } - ) + .values("copyright_license", "cohort__attribution") + .annotate(count=Count("id")) + .order_by("-count") + .values_list("copyright_license", "cohort__attribution", "count") ) - return {"license_counts": license_counts} + return [{"license": x[0], "attribution": x[1], "count": x[2]} for x in counts] @router.post( diff --git a/isic/core/templates/core/collection_detail.html b/isic/core/templates/core/collection_detail.html index e3c2be44..7eb228c3 100644 --- a/isic/core/templates/core/collection_detail.html +++ b/isic/core/templates/core/collection_detail.html @@ -28,40 +28,18 @@ -
    -
      +
      +
      • Name: {{ collection.name }}
      • - {% if request.user.is_staff %} -
      • - Creator: - {{ collection.creator }} -
      • -
      • - Created: - {% localtime collection.created %} -
      • - {% endif %} {% if collection.doi %}
      • DOI: {{ collection.doi.url }}
      • {% endif %} - {% if contributors %} -
      • - Contributors: - -
      • - {% endif %}
      • Number of images: {{ num_images|intcomma }} @@ -74,84 +52,129 @@ Number of lesions: {{ collection.num_lesions|intcomma }}
      • -
      • - Licenses: - +
      • + Attribution: + View
          -