From 7487ccf2237453b955a2d589432ea2f2778f5516 Mon Sep 17 00:00:00 2001 From: Jacob Olson Date: Wed, 11 Nov 2026 09:16:16 -0700 Subject: [PATCH] Check out from the Aliquots list; Lab Checkouts tile; in-page confirm dialog Co-Authored-By: Claude Sonnet 5.5 --- krill/krill/views/home.py | 14 +- .../reports/checked_out_no_owner.html | 6 +- krill/reports/test_checked_out_no_owner.py | 7 + krill/sample/tests/test_checkout_from_list.py | 225 ++++++++++++++++++ krill/sample/views/detail.py | 5 +- krill/sample/views/list.py | 21 +- krill/static/krill/js/confirm-dialog.js | 51 ++++ krill/static/krill/style.css | 68 ++++++ krill/templates/base/layout.html | 1 + krill/templates/krill/home.html | 18 +- krill/templates/sample/list.html | 37 ++- krill/templates/sample/tube_detail.html | 6 +- 12 files changed, 439 insertions(+), 20 deletions(-) create mode 100644 krill/sample/tests/test_checkout_from_list.py create mode 100644 krill/static/krill/js/confirm-dialog.js diff --git a/krill/krill/views/home.py b/krill/krill/views/home.py index 1ae600c..c08a812 100644 --- a/krill/krill/views/home.py +++ b/krill/krill/views/home.py @@ -10,7 +10,7 @@ from sample.models.sample import Sample from sample.models.aliquot import Aliquot, AliquotLocation from storage.models.storage import Box -from person.models import UserAuditLog, UserPreference, SiteConfiguration +from person.models import UserAuditLog, UserPreference, SiteConfiguration, UserRole from person.decorators import require_minimum_role __all__ = ( @@ -33,6 +33,7 @@ def get(self, request): 'freezers': freezers, 'show_sites': len({card['device'].site_id for card in freezers}) > 1, 'checked_out': get_checked_out(request.user), + 'lab_checkouts': get_lab_checkouts(request.user), 'audits_in_progress': get_audits_in_progress(), 'recent_activity': get_recent_activity(), }) @@ -187,6 +188,17 @@ def get_checked_out(user, limit=5): } +def get_lab_checkouts(user): + """Everyone's checked-out aliquots and how many people have them. Only for lab managers and admins.""" + if UserRole.get_or_create_for_user(user).role not in ('lab_manager', 'lab_admin'): + return None + out = Aliquot.objects.filter(checked_out_by__isnull=False, disposition__disposition_type='in_use') + return { + 'aliquots': out.count(), + 'people': out.values('checked_out_by').distinct().count(), + } + + def get_audits_in_progress(limit=3): """Storage audits that still have slots to check, most recent first.""" from reports.models import Report diff --git a/krill/reports/templates/reports/checked_out_no_owner.html b/krill/reports/templates/reports/checked_out_no_owner.html index 5a265d1..dd27984 100644 --- a/krill/reports/templates/reports/checked_out_no_owner.html +++ b/krill/reports/templates/reports/checked_out_no_owner.html @@ -96,11 +96,13 @@

Checked Out, No Owner

update(); }); rows.forEach(function (r) { r.addEventListener('change', update); }); - form.addEventListener('submit', function (e) { + // Set the message just before submit; the shared dialog (confirm-dialog.js) shows it + form.addEventListener('submit', function () { var n = rows.filter(function (r) { return r.checked; }).length; var sel = document.getElementById('bulkDisposition'); var name = sel.options[sel.selectedIndex].text; - if (!confirm('Mark ' + n + ' aliquot' + (n === 1 ? '' : 's') + ' as ' + name + '?')) e.preventDefault(); + form.setAttribute('data-confirm', 'Mark ' + n + ' aliquot' + (n === 1 ? '' : 's') + ' as ' + name + '?'); + form.setAttribute('data-confirm-label', 'Apply'); }); update(); })(); diff --git a/krill/reports/test_checked_out_no_owner.py b/krill/reports/test_checked_out_no_owner.py index 8f5bea2..2c1d769 100644 --- a/krill/reports/test_checked_out_no_owner.py +++ b/krill/reports/test_checked_out_no_owner.py @@ -90,6 +90,13 @@ def test_controls_shown_to_managers_only(self): self.assertNotContains(member_page, 'id="bulkApply"') self.assertNotContains(member_page, 'name="aliquot_ids"') + def test_apply_uses_the_shared_confirm_dialog(self): + self._aliquot('in_use') + self.client.force_login(self.manager) + html = self.client.get(self.url).content.decode() + self.assertIn("form.setAttribute('data-confirm'", html) + self.assertNotIn('confirm(', html.replace("setAttribute('data-confirm'", '')) + def test_dropdown_offers_only_exhausted_and_disposed(self): self.client.force_login(self.manager) offered = {d.disposition_type for d in self.client.get(self.url).context['target_dispositions']} diff --git a/krill/sample/tests/test_checkout_from_list.py b/krill/sample/tests/test_checkout_from_list.py new file mode 100644 index 0000000..9fd3647 --- /dev/null +++ b/krill/sample/tests/test_checkout_from_list.py @@ -0,0 +1,225 @@ +from django.contrib.auth import get_user_model +from django.urls import reverse +from django.utils import timezone + +from ..models.aliquot import Aliquot, AliquotDisposition, AliquotLocation +from .test_views import SampleViewTest + +User = get_user_model() + + +class CheckoutFixture: + def setup_dispositions(self): + self.in_use = AliquotDisposition.objects.get_or_create( + name='In Use', defaults={'disposition_type': 'in_use'})[0] + self.exhausted = AliquotDisposition.objects.get_or_create( + name='Used', defaults={'disposition_type': 'exhausted'})[0] + + def make_manager(self, username='mgr'): + manager = User.objects.create_user(username=username, password='x') + manager.role.role = 'lab_manager' + manager.role.save() + return manager + + def out(self, owner, **kwargs): + return Aliquot.objects.create( + sample=self.sample, disposition=self.in_use, + checked_out_by=owner, checked_out_at=timezone.now(), **kwargs) + + +class CheckOutButtonOnListTest(CheckoutFixture, SampleViewTest): + def setUp(self): + super().setUp() + self.setup_dispositions() + self.client.force_login(self.user) + self.list_url = reverse('sample:sample_list') + + def _list(self, **params): + return self.client.get(self.list_url, {'type': 'aliquot', **params}) + + def test_button_only_on_stored_rows(self): + in_use = Aliquot.objects.create(sample=self.sample, disposition=self.in_use) + exhausted = Aliquot.objects.create(sample=self.sample, disposition=self.exhausted) + response = self._list() + html = response.content.decode() + self.assertEqual(html.count('name="action" value="checkout"'), 1) # only self.aliquot is stored + self.assertContains(response, reverse('sample:aliquot_detail', kwargs={'pk': self.aliquot.pk})) + for other in (in_use, exhausted): + self.assertNotContains(response, f'action="{reverse("sample:aliquot_detail", kwargs={"pk": other.pk})}"') + + def test_form_returns_to_the_current_list_view(self): + response = self._list(q='Test', sort='passage') + self.assertContains(response, 'name="next" value="/samples/list/?type=aliquot&q=Test&sort=passage"') + + def test_checkout_from_list_records_owner_and_returns_to_the_list(self): + url = reverse('sample:aliquot_detail', kwargs={'pk': self.aliquot.pk}) + back = self.list_url + '?type=aliquot&q=Test' + response = self.client.post(url, {'action': 'checkout', 'next': back}) + self.assertRedirects(response, back, fetch_redirect_response=False) + self.aliquot.refresh_from_db() + self.assertEqual(self.aliquot.disposition.disposition_type, 'in_use') + self.assertEqual(self.aliquot.checked_out_by, self.user) + + def test_checkout_without_next_still_goes_to_the_aliquot_page(self): + url = reverse('sample:aliquot_detail', kwargs={'pk': self.aliquot.pk}) + self.assertRedirects(self.client.post(url, {'action': 'checkout'}), url, fetch_redirect_response=False) + + def test_foreign_next_is_ignored(self): + url = reverse('sample:aliquot_detail', kwargs={'pk': self.aliquot.pk}) + response = self.client.post(url, {'action': 'checkout', 'next': 'https://evil.example/'}) + self.assertRedirects(response, url, fetch_redirect_response=False) + + def test_stale_checkout_does_not_take_over_someone_elses_aliquot(self): + colleague = User.objects.create_user(username='colleague', password='x') + taken = self.out(colleague) + self.client.post(reverse('sample:aliquot_detail', kwargs={'pk': taken.pk}), {'action': 'checkout'}) + taken.refresh_from_db() + self.assertEqual(taken.checked_out_by, colleague) + + def test_checkout_frees_the_box_position(self): + self.aliquot.store_in_location(self.box, 1, 1) + self.client.post(reverse('sample:aliquot_detail', kwargs={'pk': self.aliquot.pk}), {'action': 'checkout'}) + self.assertFalse(AliquotLocation.objects.filter(aliquot=self.aliquot).exists()) + + +class CheckedOutByEveryoneFilterTest(CheckoutFixture, SampleViewTest): + def setUp(self): + super().setUp() + self.setup_dispositions() + self.manager = self.make_manager() + self.other = User.objects.create_user(username='aaa_colleague', password='x', first_name='Ada', last_name='Lovelace') + + def _list(self, **params): + return self.client.get(reverse('sample:sample_list'), {'type': 'aliquot', 'checked_out_by': 'all', **params}) + + def test_manager_sees_every_owned_in_use_aliquot_grouped_by_person(self): + self.client.force_login(self.manager) + mine = self.out(self.manager) + theirs = self.out(self.other) + ownerless = Aliquot.objects.create(sample=self.sample, disposition=self.in_use) + used_up = self.out(self.other) + used_up.disposition = self.exhausted + used_up.save() + response = self._list() + items = list(response.context['items']) + self.assertTrue(response.context['checked_out_all']) + self.assertNotIn(ownerless, items) + self.assertNotIn(used_up, items) + self.assertIn(mine, items) + self.assertIn(theirs, items) + # grouped by owner username: aaa_colleague before mgr + owners = [a.checked_out_by.username for a in items] + self.assertEqual(owners, sorted(owners)) + + def test_shows_who_and_chip_and_columns(self): + self.client.force_login(self.manager) + self.out(self.other) + response = self._list() + self.assertContains(response, 'Checked Out By') + self.assertContains(response, 'Checked Out') + self.assertContains(response, 'Ada Lovelace') + self.assertContains(response, 'Checked out by anyone') + self.assertContains(response, 'name="checked_out_by" value="all"') + + def test_members_cannot_use_the_all_filter(self): + self.client.force_login(self.user) # lab_member + theirs = self.out(self.other) + response = self._list() + self.assertFalse(response.context['checked_out_all']) + self.assertIn(self.aliquot, response.context['items']) # not filtered at all + self.assertIn(theirs, response.context['items']) + self.assertNotContains(response, 'Checked Out By') + + def test_an_explicit_sort_overrides_the_grouping(self): + self.client.force_login(self.manager) + a = self.out(self.manager, passage='p1') + b = self.out(self.other, passage='p2') + items = list(self._list(sort='passage', order='desc').context['items']) + self.assertEqual(items, [b, a]) + + def test_me_pill_switches_from_all_to_me(self): + self.client.force_login(self.manager) + self.assertIn('checked_out_by=me', self._list().context['checked_out_toggle_url']) + + +class LabCheckoutsTileTest(CheckoutFixture, SampleViewTest): + def setUp(self): + super().setUp() + self.setup_dispositions() + self.manager = self.make_manager() + self.other = User.objects.create_user(username='colleague', password='x') + + def test_manager_sees_the_tile_with_counts_and_link(self): + self.out(self.manager) + self.out(self.other) + self.out(self.other) + self.client.force_login(self.manager) + response = self.client.get(reverse('home')) + self.assertEqual(response.context['lab_checkouts'], {'aliquots': 3, 'people': 2}) + self.assertContains(response, 'Lab Checkouts') + self.assertContains(response, '3 aliquots · 2 people') + self.assertContains(response, '?type=aliquot&checked_out_by=all') + + def test_singular_forms(self): + self.out(self.other) + self.client.force_login(self.manager) + self.assertContains(self.client.get(reverse('home')), '1 aliquot · 1 person') + + def test_tile_counts_only_owned_in_use_aliquots(self): + Aliquot.objects.create(sample=self.sample, disposition=self.in_use) # no owner + used_up = self.out(self.other) + used_up.disposition = self.exhausted + used_up.save() + self.client.force_login(self.manager) + response = self.client.get(reverse('home')) + self.assertEqual(response.context['lab_checkouts'], {'aliquots': 0, 'people': 0}) + self.assertContains(response, 'None checked out') + + def test_members_do_not_get_the_tile(self): + self.out(self.other) + self.client.force_login(self.user) + response = self.client.get(reverse('home')) + self.assertIsNone(response.context['lab_checkouts']) + self.assertNotContains(response, 'Lab Checkouts') + + +class ConfirmDialogMarkupTest(CheckoutFixture, SampleViewTest): + """Confirmations use the in-page dialog (data-confirm), not the browser's confirm() popup.""" + + def setUp(self): + super().setUp() + self.setup_dispositions() + self.client.force_login(self.user) + + def test_layout_loads_the_dialog_script(self): + self.assertContains(self.client.get(reverse('home')), 'js/confirm-dialog.js') + + def test_list_check_out_form_has_message_and_label(self): + response = self.client.get(reverse('sample:sample_list'), {'type': 'aliquot'}) + self.assertContains( + response, + f'data-confirm="Check out Test Sample #{self.aliquot.id}? This changes its status to In Use and frees its box position."', + ) + self.assertContains(response, 'data-confirm-label="Check out"') + self.assertNotContains(response, 'onclick="return confirm(') + + def test_aliquot_page_check_out_form_has_message(self): + response = self.client.get(reverse('sample:aliquot_detail', kwargs={'pk': self.aliquot.pk})) + self.assertContains(response, 'data-confirm="Check out this aliquot? This will change its status to In Use."') + self.assertNotContains(response, 'onclick="return confirm(') + + def test_dashboard_done_form_has_message_and_label(self): + owned = self.out(self.user) + response = self.client.get(reverse('home')) + self.assertContains( + response, + f'data-confirm="Mark Test Sample #{owned.id} as exhausted, with no child recorded?"', + ) + self.assertContains(response, 'data-confirm-label="Mark exhausted"') + self.assertNotContains(response, 'onclick="return confirm(') + + def test_names_with_quotes_are_escaped_in_the_attribute(self): + self.sample.name = 'Line "A" ' + self.sample.save() + html = self.client.get(reverse('sample:sample_list'), {'type': 'aliquot'}).content.decode() + self.assertIn('data-confirm="Check out Line "A" <b> #', html) diff --git a/krill/sample/views/detail.py b/krill/sample/views/detail.py index f12ae23..9ddaf30 100644 --- a/krill/sample/views/detail.py +++ b/krill/sample/views/detail.py @@ -247,6 +247,9 @@ def _handle_done(self, request): def _handle_checkout(self, request): """Handle checkout action - change disposition to 'in_use'""" was_stored = self.object.disposition and self.object.disposition.disposition_type == 'stored' + if not was_stored: + # Another person may have checked it out since this page was loaded: do not take it over + return redirect(safe_next(request, reverse('sample:aliquot_detail', kwargs={'pk': self.object.pk}))) in_use_disposition, _ = AliquotDisposition.objects.get_or_create( name='In Use', @@ -262,4 +265,4 @@ def _handle_checkout(self, request): if was_stored: AliquotLocation.objects.filter(aliquot=self.object).delete() - return redirect('sample:aliquot_detail', pk=self.object.pk) + return redirect(safe_next(request, reverse('sample:aliquot_detail', kwargs={'pk': self.object.pk}))) diff --git a/krill/sample/views/list.py b/krill/sample/views/list.py index 54aa155..e173802 100644 --- a/krill/sample/views/list.py +++ b/krill/sample/views/list.py @@ -5,6 +5,7 @@ from ..models.sample import Sample from ..models.aliquot import Aliquot, AliquotType, AliquotDisposition, AliquotLocation from ..models.source import Source +from person.models import UserRole class SampleListView(LoginRequiredMixin, ListView): template_name = 'sample/list.html' @@ -19,6 +20,7 @@ def get_queryset(self): 'aliquot_type', 'disposition', 'location__box__rack__shelf__device__site', + 'checked_out_by', ) elif model_type == 'aliquot-type': queryset = AliquotType.objects.all() @@ -59,6 +61,12 @@ def get_queryset(self): checked_out_by=self.request.user, disposition__disposition_type='in_use', ) + elif self._checked_out_by_everyone(): + # ?checked_out_by=all: everyone's, for lab managers and admins + queryset = queryset.filter( + checked_out_by__isnull=False, + disposition__disposition_type='in_use', + ) # Hide finished (exhausted) aliquots. Disposed ones stay visible. if self.request.GET.get('hide_finished') == '1': @@ -73,7 +81,10 @@ def get_queryset(self): else: sort_prefix = '' - if model_type == 'aliquot' and sort_by == 'disposition': + if model_type == 'aliquot' and self._checked_out_by_everyone() and 'sort' not in self.request.GET: + # Group by person unless a column sort was chosen + queryset = queryset.order_by('checked_out_by__username', '-checked_out_at', 'id') + elif model_type == 'aliquot' and sort_by == 'disposition': queryset = queryset.order_by(f'{sort_prefix}disposition__disposition_type', 'id') elif model_type == 'aliquot' and sort_by == 'type': queryset = queryset.order_by(f'{sort_prefix}aliquot_type__name', 'id') @@ -131,6 +142,12 @@ def _search_aliquots(queryset, term): match |= Q(id=int(number)) return queryset.filter(match) + def _checked_out_by_everyone(self): + """True for ?checked_out_by=all, which only lab managers and admins may use.""" + if self.request.GET.get('checked_out_by') != 'all': + return False + return UserRole.get_or_create_for_user(self.request.user).role in ('lab_manager', 'lab_admin') + def _toggle_url(self, param, value): """Link that flips one yes/no filter, keeps every other parameter, and goes back to page 1.""" params = self.request.GET.copy() @@ -176,6 +193,7 @@ def get_context_data(self, **kwargs): context['aliquot_type_filter'] = self.request.GET.get('aliquot_type', '') context['hide_finished'] = self.request.GET.get('hide_finished') == '1' context['checked_out_by_me'] = self.request.GET.get('checked_out_by') == 'me' + context['checked_out_all'] = self._checked_out_by_everyone() context['checked_out_toggle_url'] = self._toggle_url('checked_out_by', 'me') context['hide_finished_toggle_url'] = self._toggle_url('hide_finished', '1') context['checked_out_count'] = Aliquot.objects.filter( @@ -191,6 +209,7 @@ def get_context_data(self, **kwargs): context['aliquot_type_filter'] = '' context['hide_finished'] = False context['checked_out_by_me'] = False + context['checked_out_all'] = False context['sample_filter'] = None context['disposition_choices'] = [] context['aliquot_types'] = AliquotType.objects.none() diff --git a/krill/static/krill/js/confirm-dialog.js b/krill/static/krill/js/confirm-dialog.js new file mode 100644 index 0000000..7eb671d --- /dev/null +++ b/krill/static/krill/js/confirm-dialog.js @@ -0,0 +1,51 @@ +// Two-click confirmation in an in-page dialog instead of the browser's confirm() popup. +// +// Add data-confirm="Message" to a
(and optionally data-confirm-label="Button text"). +// Submitting the form then shows the dialog; the form is only sent when the person confirms. +(function () { + var dialog = null; + var pendingForm = null; + + function build() { + dialog = document.createElement('dialog'); + dialog.className = 'confirm-dialog'; + dialog.setAttribute('aria-labelledby', 'confirmDialogMessage'); + dialog.innerHTML = + '

' + + '
' + + '' + + '' + + '
'; + document.body.appendChild(dialog); + + dialog.querySelector('[data-confirm-cancel]').addEventListener('click', function () { + pendingForm = null; + dialog.close(); + }); + dialog.querySelector('[data-confirm-ok]').addEventListener('click', function () { + var form = pendingForm; + pendingForm = null; + dialog.close(); + if (form) { + form.removeAttribute('data-confirm-pending'); + form.submit(); // submit() does not fire the submit event, so this does not loop + } + }); + // Esc, or a click on the dimmed backdrop, cancels + dialog.addEventListener('cancel', function () { pendingForm = null; }); + dialog.addEventListener('click', function (e) { + if (e.target === dialog) { pendingForm = null; dialog.close(); } + }); + } + + document.addEventListener('submit', function (event) { + var form = event.target; + if (!form || !form.getAttribute || !form.getAttribute('data-confirm')) return; + event.preventDefault(); + if (!dialog) build(); + pendingForm = form; + dialog.querySelector('.confirm-dialog-message').textContent = form.getAttribute('data-confirm'); + dialog.querySelector('[data-confirm-ok]').textContent = form.getAttribute('data-confirm-label') || 'Confirm'; + dialog.showModal(); + }); +})(); diff --git a/krill/static/krill/style.css b/krill/static/krill/style.css index 497c000..6c6326e 100644 --- a/krill/static/krill/style.css +++ b/krill/static/krill/style.css @@ -2629,6 +2629,74 @@ main table tbody tr:last-child td{ outline-offset: 1px; } +.btn-plain { + background: transparent; + color: var(--color-dark); + border: 1px solid var(--color-gray-border); + cursor: pointer; +} + +.btn-plain:hover { + border-color: var(--color-primary); +} + +.confirm-dialog { + /* The global `* { margin: 0 }` reset removes the browser's centring of modal dialogs */ + position: fixed; + inset: 0; + margin: auto; + height: fit-content; + max-width: 28rem; + width: calc(100% - 2rem); + padding: 1.25rem 1.5rem; + border: 1px solid var(--color-light); + border-radius: var(--border-radius-1); + background: var(--color-white); + color: var(--color-dark); + box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35); +} + +.confirm-dialog::backdrop { + background: rgba(0, 0, 0, 0.5); +} + +.confirm-dialog-message { + margin: 0 0 1.25rem; + font-size: 1rem; + line-height: 1.45; +} + +.confirm-dialog-actions { + display: flex; + justify-content: flex-end; + gap: 0.5rem; +} + +.row-actions { + display: flex; + align-items: center; + justify-content: flex-end; + gap: 8px; +} + +/* The list page's own .btn rule (border: none, 12px 24px padding) would otherwise win */ +.row-actions .btn-plain { + padding: 6px 12px; + border: 1px solid var(--color-gray-border); + border-radius: var(--border-radius-1); + background: transparent; + font-size: 0.85rem; + white-space: nowrap; +} + +.row-actions .btn-plain:hover { + border-color: var(--color-primary); +} + +.row-actions form { + margin: 0; +} + .toggle-pills { display: flex; flex-wrap: wrap; diff --git a/krill/templates/base/layout.html b/krill/templates/base/layout.html index 022fe3d..7ea2408 100644 --- a/krill/templates/base/layout.html +++ b/krill/templates/base/layout.html @@ -31,4 +31,5 @@ + {% endblock layout %} diff --git a/krill/templates/krill/home.html b/krill/templates/krill/home.html index 6e0b316..748052f 100644 --- a/krill/templates/krill/home.html +++ b/krill/templates/krill/home.html @@ -60,6 +60,15 @@

Expiring Soon

{% endif %} + {% if lab_checkouts is not None %} + + groups +
+

Lab Checkouts

+

{% if lab_checkouts.aliquots %}{{ lab_checkouts.aliquots }} aliquot{{ lab_checkouts.aliquots|pluralize }} · {{ lab_checkouts.people }} {{ lab_checkouts.people|pluralize:"person,people" }}{% else %}None checked out{% endif %}

+
+
+ {% endif %} @@ -101,12 +110,13 @@

Checked out by you ({{ checked_out.total }})

add Create child - + {% csrf_token %} - +
@@ -206,8 +216,6 @@

Recent Activity

.activity-actions .btn .material-icons-round { color: inherit; font-size: 1.1rem; } .activity-actions .btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; line-height: 1.2; } .checked-out-card { margin-top: 16px; } - .btn-plain { background: transparent; color: var(--color-dark); border: 1px solid var(--color-gray-border); cursor: pointer; } - .btn-plain:hover { border-color: var(--color-primary); } .checked-out-empty { margin: 8px 0 16px; color: var(--color-dark-variant); } .dashboard-header { margin-bottom: 20px; } .freezer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; } diff --git a/krill/templates/sample/list.html b/krill/templates/sample/list.html index d355953..d711355 100644 --- a/krill/templates/sample/list.html +++ b/krill/templates/sample/list.html @@ -20,6 +20,7 @@

{{ model_name }}

{% if sample_filter %}{% endif %} {% if checked_out_by_me %}{% endif %} + {% if checked_out_all %}{% endif %} {% if hide_finished %}{% endif %} {% if request.GET.sort %}{% endif %} {% if request.GET.order %}{% endif %} @@ -61,8 +62,14 @@

{{ model_name }}

Hide exhausted - {% if search_query or disposition_filter or aliquot_type_filter or sample_filter %} + {% if search_query or disposition_filter or aliquot_type_filter or sample_filter or checked_out_all %}
+ {% if checked_out_all %} + + Checked out by anyone + + + {% endif %} {% if search_query %} "{{ search_query }}" @@ -176,7 +183,8 @@

{{ model_name }}

Disposition Location Sample Date - {% if checked_out_by_me %}Checked Out{% endif %} + {% if checked_out_all %}Checked Out By{% endif %} + {% if checked_out_by_me or checked_out_all %}Checked Out{% endif %} @@ -198,16 +206,29 @@

{{ model_name }}

{% else %}—{% endif %} {{ item.sample_date|date:"Y-m-d"|default:"—" }} - {% if checked_out_by_me %}{{ item.checked_out_at|date:"Y-m-d H:i"|default:"—" }}{% endif %} + {% if checked_out_all %}{{ item.checked_out_by_display|default:"—" }}{% endif %} + {% if checked_out_by_me or checked_out_all %}{{ item.checked_out_at|date:"Y-m-d H:i"|default:"—" }}{% endif %} - - open_in_new - +
+ {% if item.disposition.disposition_type == 'stored' %} +
+ {% csrf_token %} + + + +
+ {% endif %} + + open_in_new + +
{% empty %} - -{% if search_query or disposition_filter or aliquot_type_filter or hide_finished or sample_filter or checked_out_by_me %} + +{% if search_query or disposition_filter or aliquot_type_filter or hide_finished or sample_filter or checked_out_by_me or checked_out_all %} No aliquots match your filters — try clearing a filter above. {% else %} No aliquots yet. Create your first aliquot to get started. diff --git a/krill/templates/sample/tube_detail.html b/krill/templates/sample/tube_detail.html index 2f68ab2..4c84fdc 100644 --- a/krill/templates/sample/tube_detail.html +++ b/krill/templates/sample/tube_detail.html @@ -17,10 +17,12 @@

science Aliquot Detail

Move {% if aliquot.disposition.disposition_type == 'stored' %} -
+ {% csrf_token %} -