From 7e081a97c0216b0daab99105e6e076cff8141d1e Mon Sep 17 00:00:00 2001 From: Xinlyu Wang Date: Thu, 14 Nov 2024 13:15:48 +0800 Subject: [PATCH 01/34] Improve person manage page --- .../templates/wamtram2/batches_curation.html | 53 +----------- .../templates/wamtram2/manage_person.html | 86 ++++++++++++++----- wamtram2/views.py | 40 +++++++-- 3 files changed, 100 insertions(+), 79 deletions(-) diff --git a/wamtram2/templates/wamtram2/batches_curation.html b/wamtram2/templates/wamtram2/batches_curation.html index 09788dc6..b4bddea9 100644 --- a/wamtram2/templates/wamtram2/batches_curation.html +++ b/wamtram2/templates/wamtram2/batches_curation.html @@ -186,48 +186,6 @@
Your Role:
{% endif %} -{% comment %}
- {% if is_paginated %} - - {% endif %} -
{% endcomment %} - - {% comment %}
- - -
{% endcomment %}
@@ -607,7 +556,7 @@ comments += ' - Night ' + night; } if (entryDate) { - comments += ' - ' + entryDate; + comments += ' - Start on the night of:' + entryDate; } $('#quickAddComments').val(comments); } diff --git a/wamtram2/templates/wamtram2/manage_person.html b/wamtram2/templates/wamtram2/manage_person.html index fd9fcbb2..2da9f97d 100644 --- a/wamtram2/templates/wamtram2/manage_person.html +++ b/wamtram2/templates/wamtram2/manage_person.html @@ -7,6 +7,7 @@ + {% endblock %} {% block breadcrumbs %} @@ -49,26 +50,20 @@

People Management

- - +
+ + + +
+
- - +
+ + + +
+
@@ -101,7 +96,9 @@

People Management

{{ person.person_id }} - {{ person.first_name }} {{ person.surname }} + + {{ person.first_name }} {{ person.surname }} +
+ + {% endblock %} {% block extra_js %} {{ block.super }} +{% endblock %} \ No newline at end of file diff --git a/wamtram2/urls.py b/wamtram2/urls.py index 40e5c0b4..6c8fb019 100644 --- a/wamtram2/urls.py +++ b/wamtram2/urls.py @@ -51,5 +51,5 @@ path('curation/transfer-observations-by-tag/', views.TransferObservationsByTagView.as_view(), name='transfer_observations_by_tag'), path('curation/nesting-seasons/', views.NestingSeasonListView.as_view(), name='nesting_season_list'), path('curation/batches/', views.BatchCurationView.as_view(), name='batch_curation'), - path('curation/batch//entries/', views.BatchCurationView.as_view(), name='batch_entries'), + path('curation/batch//entries/', views.EntryCurationView.as_view(), name='batch_entries'), ] diff --git a/wamtram2/views.py b/wamtram2/views.py index 8ab6efc4..0fd5f826 100644 --- a/wamtram2/views.py +++ b/wamtram2/views.py @@ -3396,3 +3396,123 @@ def post(self, request, *args, **kwargs): return HttpResponseBadRequest() + +class EntryCurationView(LoginRequiredMixin, PaginateMixin, ListView): + model = TrtDataEntry + template_name = 'wamtram2/entry_curation_list.html' + context_object_name = 'entries' + paginate_by = 50 + + def get_queryset(self): + batch_id = self.kwargs.get('batch_id') + queryset = super().get_queryset().filter(entry_batch_id=batch_id) + + # Add all necessary related fields + queryset = queryset.select_related( + 'species_code', + 'place_code', + 'activity_code', + 'nesting', + 'entered_person_id', + 'measured_by_id', + 'recorded_by_id', + 'tagged_by_id', + 'entered_by_id', + 'measured_recorded_by_id', + 'egg_count_method', + 'clutch_completed', + 'alive', + 'interrupted', + 'flipper_tag_check', + 'pit_tag_check', + 'injury_check', + 'scar_check' + ) + + search = self.request.GET.get('search') + if search: + queryset = queryset.filter( + Q(comments__icontains=search) | + Q(turtle_comments__icontains=search) | + Q(species_code__code__icontains=search) + ) + + return queryset + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + + # Define all possible columns + all_columns = [ + # Basic Information + {'field': 'data_entry_id', 'title': 'Entry ID', 'visible': True}, + {'field': 'species_code', 'title': 'Species', 'visible': True}, + {'field': 'place_code', 'title': 'Location', 'visible': True}, + {'field': 'observation_date', 'title': 'Observation Date', 'visible': True}, + {'field': 'observation_time', 'title': 'Observation Time', 'visible': False}, + {'field': 'do_not_process', 'title': 'Flagged', 'visible': True}, + + # Measurements + {'field': 'curved_carapace_length', 'title': 'CCL', 'visible': True}, + {'field': 'curved_carapace_width', 'title': 'CCW', 'visible': True}, + {'field': 'curved_carapace_length_notch', 'title': 'CCL Notch', 'visible': False}, + + # Status and Activities + {'field': 'alive', 'title': 'Alive', 'visible': True}, + {'field': 'activity_code', 'title': 'Activity', 'visible': True}, + {'field': 'nesting', 'title': 'Nesting', 'visible': True}, + {'field': 'interrupted', 'title': 'Interrupted', 'visible': False}, + + # Tags + {'field': 'recapture_left_tag_id', 'title': 'Recap Left Tag', 'visible': False}, + {'field': 'recapture_right_tag_id', 'title': 'Recap Right Tag', 'visible': False}, + {'field': 'recapture_pittag_id', 'title': 'Recap PIT Tag', 'visible': False}, + {'field': 'new_left_tag_id', 'title': 'New Left Tag', 'visible': False}, + {'field': 'new_right_tag_id', 'title': 'New Right Tag', 'visible': False}, + {'field': 'new_pittag_id', 'title': 'New PIT Tag', 'visible': False}, + + # Checks + {'field': 'flipper_tag_check', 'title': 'Tag Check', 'visible': False}, + {'field': 'pit_tag_check', 'title': 'PIT Check', 'visible': False}, + {'field': 'injury_check', 'title': 'Injury Check', 'visible': False}, + {'field': 'scar_check', 'title': 'Scar Check', 'visible': False}, + + # Nesting Data + {'field': 'egg_count', 'title': 'Egg Count', 'visible': False}, + {'field': 'egg_count_method', 'title': 'Count Method', 'visible': False}, + {'field': 'clutch_completed', 'title': 'Clutch Complete', 'visible': False}, + + # Personnel + {'field': 'measured_by_id', 'title': 'Measured By', 'visible': False}, + {'field': 'recorded_by_id', 'title': 'Recorded By', 'visible': False}, + {'field': 'tagged_by_id', 'title': 'Tagged By', 'visible': False}, + {'field': 'entered_by_id', 'title': 'Entered By', 'visible': False}, + + # Comments + {'field': 'comments', 'title': 'Comments', 'visible': False}, + {'field': 'turtle_comments', 'title': 'Turtle Comments', 'visible': False}, + {'field': 'error_message', 'title': 'Error Message', 'visible': False}, + ] + + # Get column display settings from user session + user_columns = self.request.session.get('entry_grid_columns', [col['field'] for col in all_columns if col['visible']]) + + batch_id = self.kwargs.get('batch_id') + + context.update({ + 'all_columns': all_columns, + 'visible_columns': user_columns, + 'search_term': self.request.GET.get('search', ''), + 'clear_url': reverse('wamtram2:batch_entries', kwargs={'batch_id': batch_id}), + 'batch_id': batch_id, + }) + return context + + def post(self, request, *args, **kwargs): + if request.headers.get('X-Requested-With') == 'XMLHttpRequest': + visible_columns = request.POST.getlist('columns[]') + request.session['entry_grid_columns'] = visible_columns + return JsonResponse({'status': 'success'}) + return HttpResponseBadRequest() + + From f4f82fb86347b1be0377aa8565e4701c3a210678 Mon Sep 17 00:00:00 2001 From: Xinlyu Wang Date: Fri, 15 Nov 2024 12:26:18 +0800 Subject: [PATCH 09/34] Create entry curation list view --- .../wamtram2/ entry_curation_list.html | 235 ---------- .../wamtram2/entry_curation_list.html | 429 ++++++++++++++++++ ...son_list.html => nesting_season_list.html} | 0 wamtram2/views.py | 213 ++++++--- 4 files changed, 585 insertions(+), 292 deletions(-) delete mode 100644 wamtram2/templates/wamtram2/ entry_curation_list.html create mode 100644 wamtram2/templates/wamtram2/entry_curation_list.html rename wamtram2/templates/wamtram2/{ nesting_season_list.html => nesting_season_list.html} (100%) diff --git a/wamtram2/templates/wamtram2/ entry_curation_list.html b/wamtram2/templates/wamtram2/ entry_curation_list.html deleted file mode 100644 index c861118b..00000000 --- a/wamtram2/templates/wamtram2/ entry_curation_list.html +++ /dev/null @@ -1,235 +0,0 @@ -{% extends "base_wastd.html" %} -{% load static bootstrap4 %} - -{% block extra_style %} - {{ block.super }} - {{ form.media.css }} - - - -{% endblock %} - -{% block content %} -
- - -
-
-

Entries for Batch {{ batch_id }}

-
-
- -
-
- -
-
-
- {% include "includes/search_form.html" with placeholder="Search comments or species..." %} -
-
-
- {% if is_paginated %} - {% include "pagination.html" %} - {% endif %} -
-
- -
- - - - {% for column in all_columns %} - {% if column.field in visible_columns %} - - {% endif %} - {% endfor %} - - - - {% for entry in entries %} - - {% for column in all_columns %} - {% if column.field in visible_columns %} - - {% endif %} - {% endfor %} - - {% endfor %} - -
{{ column.title }}
- {% if column.field == 'data_entry_id' %} - {{ entry.data_entry_id }} - {% elif column.field == 'species_code' %} - {{ entry.species_code|default:"-" }} - {% elif column.field == 'place_code' %} - {{ entry.place_code|default:"-" }} - {% elif column.field == 'observation_date' %} - {{ entry.observation_date|date:"Y-m-d"|default:"-" }} - {% elif column.field == 'observation_time' %} - {{ entry.observation_time|date:"H:i"|default:"-" }} - {% elif column.field == 'nesting' %} - {{ entry.nesting|default:"-" }} - {% elif column.field == 'interrupted' %} - {{ entry.interrupted|default:"-" }} - {% elif column.field == 'curved_carapace_length' %} - {{ entry.curved_carapace_length|default:"-" }} - {% elif column.field == 'curved_carapace_width' %} - {{ entry.curved_carapace_width|default:"-" }} - {% elif column.field == 'curved_carapace_length_notch' %} - {{ entry.curved_carapace_length_notch|default:"-" }} - {% elif column.field == 'activity_code' %} - {{ entry.activity_code|default:"-" }} - {% elif column.field == 'alive' %} - {{ entry.alive|default:"-" }} - {% elif column.field == 'do_not_process' %} - {{ entry.do_not_process|yesno:"Yes,No" }} - {% elif column.field == 'recapture_left_tag_id' %} - {{ entry.recapture_left_tag_id|default:"-" }} - {% elif column.field == 'recapture_right_tag_id' %} - {{ entry.recapture_right_tag_id|default:"-" }} - {% elif column.field == 'recapture_pittag_id' %} - {{ entry.recapture_pittag_id|default:"-" }} - {% elif column.field == 'new_left_tag_id' %} - {{ entry.new_left_tag_id|default:"-" }} - {% elif column.field == 'new_right_tag_id' %} - {{ entry.new_right_tag_id|default:"-" }} - {% elif column.field == 'new_pittag_id' %} - {{ entry.new_pittag_id|default:"-" }} - {% elif column.field == 'flipper_tag_check' %} - {{ entry.flipper_tag_check|default:"-" }} - {% elif column.field == 'pit_tag_check' %} - {{ entry.pit_tag_check|default:"-" }} - {% elif column.field == 'injury_check' %} - {{ entry.injury_check|default:"-" }} - {% elif column.field == 'scar_check' %} - {{ entry.scar_check|default:"-" }} - {% elif column.field == 'egg_count' %} - {{ entry.egg_count|default:"-" }} - {% elif column.field == 'egg_count_method' %} - {{ entry.egg_count_method|default:"-" }} - {% elif column.field == 'clutch_completed' %} - {{ entry.clutch_completed|default:"-" }} - {% elif column.field == 'measured_by_id' %} - {{ entry.measured_by_id|default:"-" }} - {% elif column.field == 'recorded_by_id' %} - {{ entry.recorded_by_id|default:"-" }} - {% elif column.field == 'tagged_by_id' %} - {{ entry.tagged_by_id|default:"-" }} - {% elif column.field == 'entered_by_id' %} - {{ entry.entered_by_id|default:"-" }} - {% elif column.field == 'comments' %} - {{ entry.comments|default:"-" }} - {% elif column.field == 'turtle_comments' %} - {{ entry.turtle_comments|default:"-" }} - {% elif column.field == 'error_message' %} - {{ entry.error_message|default:"-" }} - {% endif %} -
-
-
- - - - - - - - - - -{% endblock %} - -{% block extra_js %} -{{ block.super }} - -{% endblock %} \ No newline at end of file diff --git a/wamtram2/templates/wamtram2/entry_curation_list.html b/wamtram2/templates/wamtram2/entry_curation_list.html new file mode 100644 index 00000000..8cc6ed81 --- /dev/null +++ b/wamtram2/templates/wamtram2/entry_curation_list.html @@ -0,0 +1,429 @@ +{% extends "base_wastd.html" %} +{% load static bootstrap4 %} + +{% block extra_style %} + {{ block.super }} + {{ form.media.css }} + + + +{% endblock %} + +{% block breadcrumbs %} + +{% endblock %} + + +{% block content %} +
+ +
+
+

Entries for Batch {{ batch_id }}

+
+
+ +
+
+ +
+
+
+ {% include "includes/search_form.html" with placeholder="Search comments or species..." %} +
+
+
+ {% if is_paginated %} + {% include "pagination.html" %} + {% endif %} +
+
+ +
+ + + + {% for column in all_columns %} + {% if column.field in visible_columns %} + + {% endif %} + {% endfor %} + + + + {% for entry in entries %} + + {% for column in all_columns %} + {% if column.field in visible_columns %} + + {% endif %} + {% endfor %} + + {% endfor %} + +
{{ column.title }}
+ {% if column.field == 'data_entry_id' %} + {{ entry.data_entry_id }} + + + {% elif column.field == 'species_code' %} + {{ entry.species_code|default:"-" }} + {% elif column.field == 'place_code' %} + {{ entry.place_code|default:"-" }} + {% elif column.field == 'observation_date' %} + {{ entry.observation_date|date:"Y-m-d"|default:"-" }} + {% elif column.field == 'observation_time' %} + {{ entry.observation_time|date:"H:i"|default:"-" }} + {% elif column.field == 'do_not_process' %} + {{ entry.do_not_process|yesno:"Yes,No" }} + + + {% elif column.field == 'curved_carapace_length' %} + {{ entry.curved_carapace_length|default:"-" }} + {% elif column.field == 'curved_carapace_width' %} + {{ entry.curved_carapace_width|default:"-" }} + {% elif column.field == 'curved_carapace_length_notch' %} + {{ entry.curved_carapace_length_notch|default:"-" }} + {% elif column.field == 'cc_length_not_measured' %} + {{ entry.cc_length_not_measured|yesno:"Yes,No" }} + {% elif column.field == 'cc_width_not_measured' %} + {{ entry.cc_width_not_measured|yesno:"Yes,No" }} + {% elif column.field == 'cc_notch_length_not_measured' %} + {{ entry.cc_notch_length_not_measured|yesno:"Yes,No" }} + + + {% elif column.field == 'measurement_type_1' %} + {{ entry.measurement_type_1|default:"-" }} + {% elif column.field == 'measurement_value_1' %} + {{ entry.measurement_value_1|default:"-" }} + {% elif column.field == 'measurement_type_2' %} + {{ entry.measurement_type_2|default:"-" }} + {% elif column.field == 'measurement_value_2' %} + {{ entry.measurement_value_2|default:"-" }} + {% elif column.field == 'measurement_type_3' %} + {{ entry.measurement_type_3|default:"-" }} + {% elif column.field == 'measurement_value_3' %} + {{ entry.measurement_value_3|default:"-" }} + {% elif column.field == 'measurement_type_4' %} + {{ entry.measurement_type_4|default:"-" }} + {% elif column.field == 'measurement_value_4' %} + {{ entry.measurement_value_4|default:"-" }} + {% elif column.field == 'measurement_type_5' %} + {{ entry.measurement_type_5|default:"-" }} + {% elif column.field == 'measurement_value_5' %} + {{ entry.measurement_value_5|default:"-" }} + {% elif column.field == 'measurement_type_6' %} + {{ entry.measurement_type_6|default:"-" }} + {% elif column.field == 'measurement_value_6' %} + {{ entry.measurement_value_6|default:"-" }} + + + {% elif column.field == 'alive' %} + {{ entry.alive|default:"-" }} + {% elif column.field == 'activity_code' %} + {{ entry.activity_code|default:"-" }} + {% elif column.field == 'nesting' %} + {{ entry.nesting|default:"-" }} + {% elif column.field == 'interrupted' %} + {{ entry.interrupted|default:"-" }} + {% elif column.field == 'identification_confidence' %} + {{ entry.identification_confidence|default:"-" }} + + + {% elif column.field == 'recapture_left_tag_id' %} + {{ entry.recapture_left_tag_id|default:"-" }} + {% elif column.field == 'recapture_left_tag_id_2' %} + {{ entry.recapture_left_tag_id_2|default:"-" }} + {% elif column.field == 'recapture_left_tag_id_3' %} + {{ entry.recapture_left_tag_id_3|default:"-" }} + {% elif column.field == 'recapture_right_tag_id' %} + {{ entry.recapture_right_tag_id|default:"-" }} + {% elif column.field == 'recapture_right_tag_id_2' %} + {{ entry.recapture_right_tag_id_2|default:"-" }} + {% elif column.field == 'recapture_right_tag_id_3' %} + {{ entry.recapture_right_tag_id_3|default:"-" }} + {% elif column.field == 'recapture_pittag_id' %} + {{ entry.recapture_pittag_id|default:"-" }} + {% elif column.field == 'recapture_pittag_id_2' %} + {{ entry.recapture_pittag_id_2|default:"-" }} + {% elif column.field == 'recapture_pittag_id_3' %} + {{ entry.recapture_pittag_id_3|default:"-" }} + {% elif column.field == 'recapture_pittag_id_4' %} + {{ entry.recapture_pittag_id_4|default:"-" }} + + + {% elif column.field == 'new_left_tag_id' %} + {{ entry.new_left_tag_id|default:"-" }} + {% elif column.field == 'new_left_tag_id_2' %} + {{ entry.new_left_tag_id_2|default:"-" }} + {% elif column.field == 'new_right_tag_id' %} + {{ entry.new_right_tag_id|default:"-" }} + {% elif column.field == 'new_right_tag_id_2' %} + {{ entry.new_right_tag_id_2|default:"-" }} + {% elif column.field == 'new_pittag_id' %} + {{ entry.new_pittag_id|default:"-" }} + {% elif column.field == 'new_pittag_id_2' %} + {{ entry.new_pittag_id_2|default:"-" }} + {% elif column.field == 'new_pittag_id_3' %} + {{ entry.new_pittag_id_3|default:"-" }} + {% elif column.field == 'new_pittag_id_4' %} + {{ entry.new_pittag_id_4|default:"-" }} + + + {% elif column.field == 'other_left_tag' %} + {{ entry.other_left_tag|default:"-" }} + {% elif column.field == 'other_right_tag' %} + {{ entry.other_right_tag|default:"-" }} + {% elif column.field == 'other_tags' %} + {{ entry.other_tags|default:"-" }} + + + {% elif column.field == 'dud_flipper_tag' %} + {{ entry.dud_flipper_tag|default:"-" }} + {% elif column.field == 'dud_flipper_tag_2' %} + {{ entry.dud_flipper_tag_2|default:"-" }} + {% elif column.field == 'dud_pit_tag' %} + {{ entry.dud_pit_tag|default:"-" }} + {% elif column.field == 'dud_pit_tag_2' %} + {{ entry.dud_pit_tag_2|default:"-" }} + + + {% elif column.field == 'recapture_left_tag_state' %} + {{ entry.recapture_left_tag_state|default:"-" }} + {% elif column.field == 'recapture_left_tag_state_2' %} + {{ entry.recapture_left_tag_state_2|default:"-" }} + {% elif column.field == 'recapture_right_tag_state' %} + {{ entry.recapture_right_tag_state|default:"-" }} + {% elif column.field == 'recapture_right_tag_state_2' %} + {{ entry.recapture_right_tag_state_2|default:"-" }} + {% elif column.field == 'new_left_tag_state' %} + {{ entry.new_left_tag_state|default:"-" }} + {% elif column.field == 'new_left_tag_state_2' %} + {{ entry.new_left_tag_state_2|default:"-" }} + {% elif column.field == 'new_right_tag_state' %} + {{ entry.new_right_tag_state|default:"-" }} + {% elif column.field == 'new_right_tag_state_2' %} + {{ entry.new_right_tag_state_2|default:"-" }} + + + {% elif column.field == 'new_pit_tag_sticker_present' %} + {{ entry.new_pit_tag_sticker_present|yesno:"Yes,No" }} + {% elif column.field == 'new_pit_tag_2_sticker_present' %} + {{ entry.new_pit_tag_2_sticker_present|yesno:"Yes,No" }} + {% elif column.field == 'new_pit_tag_3_sticker_present' %} + {{ entry.new_pit_tag_3_sticker_present|yesno:"Yes,No" }} + {% elif column.field == 'new_pit_tag_4_sticker_present' %} + {{ entry.new_pit_tag_4_sticker_present|yesno:"Yes,No" }} + + + {% elif column.field == 'flipper_tag_check' %} + {{ entry.flipper_tag_check|default:"-" }} + {% elif column.field == 'pit_tag_check' %} + {{ entry.pit_tag_check|default:"-" }} + {% elif column.field == 'injury_check' %} + {{ entry.injury_check|default:"-" }} + {% elif column.field == 'scar_check' %} + {{ entry.scar_check|default:"-" }} + + + {% elif column.field == 'damage_carapace' %} + {{ entry.damage_carapace|default:"-" }} + {% elif column.field == 'damage_lff' %} + {{ entry.damage_lff|default:"-" }} + {% elif column.field == 'damage_rff' %} + {{ entry.damage_rff|default:"-" }} + {% elif column.field == 'damage_lhf' %} + {{ entry.damage_lhf|default:"-" }} + {% elif column.field == 'damage_rhf' %} + {{ entry.damage_rhf|default:"-" }} + + + {% elif column.field == 'body_part_1' %} + {{ entry.body_part_1|default:"-" }} + {% elif column.field == 'damage_code_1' %} + {{ entry.damage_code_1|default:"-" }} + {% elif column.field == 'body_part_2' %} + {{ entry.body_part_2|default:"-" }} + {% elif column.field == 'damage_code_2' %} + {{ entry.damage_code_2|default:"-" }} + {% elif column.field == 'body_part_3' %} + {{ entry.body_part_3|default:"-" }} + {% elif column.field == 'damage_code_3' %} + {{ entry.damage_code_3|default:"-" }} + {% elif column.field == 'body_part_4' %} + {{ entry.body_part_4|default:"-" }} + {% elif column.field == 'damage_code_4' %} + {{ entry.damage_code_4|default:"-" }} + {% elif column.field == 'body_part_5' %} + {{ entry.body_part_5|default:"-" }} + {% elif column.field == 'damage_code_5' %} + {{ entry.damage_code_5|default:"-" }} + {% elif column.field == 'body_part_6' %} + {{ entry.body_part_6|default:"-" }} + {% elif column.field == 'damage_code_6' %} + {{ entry.damage_code_6|default:"-" }} + + + {% elif column.field == 'tissue_type_1' %} + {{ entry.tissue_type_1|default:"-" }} + {% elif column.field == 'sample_label_1' %} + {{ entry.sample_label_1|default:"-" }} + {% elif column.field == 'tissue_type_2' %} + {{ entry.tissue_type_2|default:"-" }} + {% elif column.field == 'sample_label_2' %} + {{ entry.sample_label_2|default:"-" }} + + + {% elif column.field == 'measured_by_id' %} + {{ entry.measured_by_id|default:"-" }} + {% elif column.field == 'recorded_by_id' %} + {{ entry.recorded_by_id|default:"-" }} + {% elif column.field == 'tagged_by_id' %} + {{ entry.tagged_by_id|default:"-" }} + {% elif column.field == 'entered_by_id' %} + {{ entry.entered_by_id|default:"-" }} + {% elif column.field == 'measured_recorded_by_id' %} + {{ entry.measured_recorded_by_id|default:"-" }} + + + {% elif column.field == 'comments' %} + {{ entry.comments|default:"-" }} + {% elif column.field == 'turtle_comments' %} + {{ entry.turtle_comments|default:"-" }} + {% elif column.field == 'comment_fromrecordedtagstable' %} + {{ entry.comment_fromrecordedtagstable|default:"-" }} + {% elif column.field == 'error_message' %} + {{ entry.error_message|default:"-" }} + {% elif column.field == 'error_number' %} + {{ entry.error_number|default:"-" }} + + {% else %} + {{ entry.field|default:"-" }} + {% endif %} +
+
+ + + +{% endblock %} + +{% block extra_js %} +{{ block.super }} + +{% endblock %} \ No newline at end of file diff --git a/wamtram2/templates/wamtram2/ nesting_season_list.html b/wamtram2/templates/wamtram2/nesting_season_list.html similarity index 100% rename from wamtram2/templates/wamtram2/ nesting_season_list.html rename to wamtram2/templates/wamtram2/nesting_season_list.html diff --git a/wamtram2/views.py b/wamtram2/views.py index 0fd5f826..e2a552ce 100644 --- a/wamtram2/views.py +++ b/wamtram2/views.py @@ -3407,13 +3407,13 @@ def get_queryset(self): batch_id = self.kwargs.get('batch_id') queryset = super().get_queryset().filter(entry_batch_id=batch_id) - # Add all necessary related fields queryset = queryset.select_related( 'species_code', 'place_code', 'activity_code', 'nesting', - 'entered_person_id', + 'interrupted', + 'alive', 'measured_by_id', 'recorded_by_id', 'tagged_by_id', @@ -3421,12 +3421,50 @@ def get_queryset(self): 'measured_recorded_by_id', 'egg_count_method', 'clutch_completed', - 'alive', - 'interrupted', 'flipper_tag_check', 'pit_tag_check', 'injury_check', - 'scar_check' + 'scar_check', + 'recapture_left_tag_id', + 'recapture_left_tag_id_2', + 'recapture_left_tag_id_3', + 'recapture_right_tag_id', + 'recapture_right_tag_id_2', + 'recapture_right_tag_id_3', + 'recapture_pittag_id', + 'recapture_pittag_id_2', + 'recapture_pittag_id_3', + 'recapture_pittag_id_4', + 'new_left_tag_id', + 'new_left_tag_id_2', + 'new_right_tag_id', + 'new_right_tag_id_2', + 'new_pittag_id', + 'new_pittag_id_2', + 'new_pittag_id_3', + 'new_pittag_id_4', + 'body_part_1', + 'body_part_2', + 'body_part_3', + 'damage_code_1', + 'damage_code_2', + 'damage_code_3', + 'tissue_type_1', + 'tissue_type_2', + 'measurement_type_1', + 'measurement_type_2', + 'measurement_type_3', + 'measurement_type_4', + 'measurement_type_5', + 'measurement_type_6', + 'recapture_left_tag_state', + 'recapture_left_tag_state_2', + 'recapture_right_tag_state', + 'recapture_right_tag_state_2', + 'new_left_tag_state', + 'new_left_tag_state_2', + 'new_right_tag_state', + 'new_right_tag_state_2' ) search = self.request.GET.get('search') @@ -3442,60 +3480,121 @@ def get_queryset(self): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - # Define all possible columns - all_columns = [ - # Basic Information - {'field': 'data_entry_id', 'title': 'Entry ID', 'visible': True}, - {'field': 'species_code', 'title': 'Species', 'visible': True}, - {'field': 'place_code', 'title': 'Location', 'visible': True}, - {'field': 'observation_date', 'title': 'Observation Date', 'visible': True}, - {'field': 'observation_time', 'title': 'Observation Time', 'visible': False}, - {'field': 'do_not_process', 'title': 'Flagged', 'visible': True}, - - # Measurements - {'field': 'curved_carapace_length', 'title': 'CCL', 'visible': True}, - {'field': 'curved_carapace_width', 'title': 'CCW', 'visible': True}, - {'field': 'curved_carapace_length_notch', 'title': 'CCL Notch', 'visible': False}, - - # Status and Activities - {'field': 'alive', 'title': 'Alive', 'visible': True}, - {'field': 'activity_code', 'title': 'Activity', 'visible': True}, - {'field': 'nesting', 'title': 'Nesting', 'visible': True}, - {'field': 'interrupted', 'title': 'Interrupted', 'visible': False}, - - # Tags - {'field': 'recapture_left_tag_id', 'title': 'Recap Left Tag', 'visible': False}, - {'field': 'recapture_right_tag_id', 'title': 'Recap Right Tag', 'visible': False}, - {'field': 'recapture_pittag_id', 'title': 'Recap PIT Tag', 'visible': False}, - {'field': 'new_left_tag_id', 'title': 'New Left Tag', 'visible': False}, - {'field': 'new_right_tag_id', 'title': 'New Right Tag', 'visible': False}, - {'field': 'new_pittag_id', 'title': 'New PIT Tag', 'visible': False}, - - # Checks - {'field': 'flipper_tag_check', 'title': 'Tag Check', 'visible': False}, - {'field': 'pit_tag_check', 'title': 'PIT Check', 'visible': False}, - {'field': 'injury_check', 'title': 'Injury Check', 'visible': False}, - {'field': 'scar_check', 'title': 'Scar Check', 'visible': False}, - - # Nesting Data - {'field': 'egg_count', 'title': 'Egg Count', 'visible': False}, - {'field': 'egg_count_method', 'title': 'Count Method', 'visible': False}, - {'field': 'clutch_completed', 'title': 'Clutch Complete', 'visible': False}, - - # Personnel - {'field': 'measured_by_id', 'title': 'Measured By', 'visible': False}, - {'field': 'recorded_by_id', 'title': 'Recorded By', 'visible': False}, - {'field': 'tagged_by_id', 'title': 'Tagged By', 'visible': False}, - {'field': 'entered_by_id', 'title': 'Entered By', 'visible': False}, + model_fields = TrtDataEntry._meta.get_fields() + + all_columns = [] + + default_visible_fields = { + 'data_entry_id', 'species_code', 'place_code', + 'observation_date', 'do_not_process', 'curved_carapace_length', + 'curved_carapace_width', 'alive', 'activity_code', 'nesting' + } + + field_groups = { + 'Basic Information': [ + 'data_entry_id', 'species_code', 'place_code', + 'observation_date', 'observation_time', 'do_not_process' + ], + 'Measurements': [ + 'curved_carapace_length', 'curved_carapace_width', + 'curved_carapace_length_notch', 'cc_length_not_measured', + 'cc_width_not_measured', 'cc_notch_length_not_measured', + 'measurement_type_1', 'measurement_value_1', + 'measurement_type_2', 'measurement_value_2', + 'measurement_type_3', 'measurement_value_3', + 'measurement_type_4', 'measurement_value_4', + 'measurement_type_5', 'measurement_value_5', + 'measurement_type_6', 'measurement_value_6' + ], + 'Status and Activities': [ + 'alive', 'activity_code', 'nesting', 'interrupted', + 'identification_confidence' + ], + 'Tags': [ + 'recapture_left_tag_id', 'recapture_left_tag_id_2', 'recapture_left_tag_id_3', + 'recapture_right_tag_id', 'recapture_right_tag_id_2', 'recapture_right_tag_id_3', + 'recapture_pittag_id', 'recapture_pittag_id_2', 'recapture_pittag_id_3', 'recapture_pittag_id_4', + 'new_left_tag_id', 'new_left_tag_id_2', + 'new_right_tag_id', 'new_right_tag_id_2', + 'new_pittag_id', 'new_pittag_id_2', 'new_pittag_id_3', 'new_pittag_id_4', + 'other_left_tag', 'other_right_tag', 'other_tags', + 'other_tags_identification_type', + 'dud_flipper_tag', 'dud_flipper_tag_2', + 'dud_pit_tag', 'dud_pit_tag_2' + ], + 'Tag States': [ + 'recapture_left_tag_state', 'recapture_left_tag_state_2', + 'recapture_right_tag_state', 'recapture_right_tag_state_2', + 'new_left_tag_state', 'new_left_tag_state_2', + 'new_right_tag_state', 'new_right_tag_state_2' + ], + 'PIT Tag Stickers': [ + 'new_pit_tag_sticker_present', 'new_pit_tag_2_sticker_present', + 'new_pit_tag_3_sticker_present', 'new_pit_tag_4_sticker_present' + ], + 'Checks': [ + 'flipper_tag_check', 'pit_tag_check', 'injury_check', 'scar_check', + 'tagscarnotchecked', 'didnotcheckforinjury' + ], + 'Damage and Scars': [ + 'damage_carapace', 'damage_lff', 'damage_rff', 'damage_lhf', 'damage_rhf', + 'body_part_1', 'damage_code_1', + 'body_part_2', 'damage_code_2', + 'body_part_3', 'damage_code_3', + 'scars_left', 'scars_right', + 'scars_left_scale_1', 'scars_left_scale_2', 'scars_left_scale_3', + 'scars_right_scale_1', 'scars_right_scale_2', 'scars_right_scale_3' + ], + 'Tissue Samples': [ + 'tissue_type_1', 'sample_label_1', + 'tissue_type_2', 'sample_label_2' + ], + 'Nesting Data': [ + 'egg_count', 'egg_count_method', 'clutch_completed' + ], + 'Personnel': [ + 'measured_by_id', 'recorded_by_id', 'tagged_by_id', + 'entered_by_id', 'measured_recorded_by_id' + ], + 'Comments': [ + 'comments', 'turtle_comments', 'comment_fromrecordedtagstable', + 'error_message', 'error_number' + ] + } + + + processed_fields = set() + + for group_name, field_patterns in field_groups.items(): + group_fields = [] + for field in model_fields: + if hasattr(field, 'name'): + field_name = field.name + + if any(pattern in field_name for pattern in field_patterns) or field_name in field_patterns: + group_fields.append({ + 'field': field_name, + 'title': field_name.replace('_', ' ').title(), + 'visible': field_name in default_visible_fields, + 'group': group_name + }) + processed_fields.add(field_name) - # Comments - {'field': 'comments', 'title': 'Comments', 'visible': False}, - {'field': 'turtle_comments', 'title': 'Turtle Comments', 'visible': False}, - {'field': 'error_message', 'title': 'Error Message', 'visible': False}, - ] + + all_columns.extend(sorted(group_fields, key=lambda x: x['field'])) + + + for field in model_fields: + if hasattr(field, 'name') and field.name not in processed_fields: + all_columns.append({ + 'field': field.name, + 'title': field.name.replace('_', ' ').title(), + 'visible': field.name in default_visible_fields, + 'group': 'Other' + }) - # Get column display settings from user session - user_columns = self.request.session.get('entry_grid_columns', [col['field'] for col in all_columns if col['visible']]) + user_columns = self.request.session.get('entry_grid_columns', + [col['field'] for col in all_columns if col['visible']]) batch_id = self.kwargs.get('batch_id') From 785ff9125e94559e3002465e34f0ba962782f4b0 Mon Sep 17 00:00:00 2001 From: Rick Wang Date: Fri, 15 Nov 2024 13:55:50 +0800 Subject: [PATCH 10/34] Fix entry curation list view --- wamtram2/static/css/grid.css | 13 +++++++++---- .../templates/wamtram2/entry_curation_list.html | 3 +-- wamtram2/views.py | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/wamtram2/static/css/grid.css b/wamtram2/static/css/grid.css index e99ba4aa..73ab0cbb 100644 --- a/wamtram2/static/css/grid.css +++ b/wamtram2/static/css/grid.css @@ -1,6 +1,7 @@ .grid-container { - overflow-x: auto; + overflow-y: auto; position: relative; + height: 40%; margin: 1rem 0; border: 1px solid #dee2e6; border-radius: 0.25rem; @@ -15,11 +16,15 @@ border-collapse: collapse; } +.grid-table thead { + position: sticky; + top:0; + background-color: #fff; + z-index: 1; +} + .grid-table th { - position: sticky; - top: 0; background: #f8f9fa; - z-index: 1; font-weight: 500; border-bottom: 2px solid #dee2e6; padding: 0.75rem; diff --git a/wamtram2/templates/wamtram2/entry_curation_list.html b/wamtram2/templates/wamtram2/entry_curation_list.html index 8cc6ed81..f6f6b97a 100644 --- a/wamtram2/templates/wamtram2/entry_curation_list.html +++ b/wamtram2/templates/wamtram2/entry_curation_list.html @@ -21,7 +21,7 @@ {% endblock %} -{% block content %} +{% block page_content_inner %}
@@ -382,7 +382,6 @@

function viewEntry(entryId) { console.log('Clicked entry:', entryId); // TODO: Implement entry detail view - // window.location.href = "{% url 'wamtram2:entry_detail' 0 %}".replace('0', entryId); } $(document).ready(function() { diff --git a/wamtram2/views.py b/wamtram2/views.py index e2a552ce..f38bf9d7 100644 --- a/wamtram2/views.py +++ b/wamtram2/views.py @@ -3401,7 +3401,7 @@ class EntryCurationView(LoginRequiredMixin, PaginateMixin, ListView): model = TrtDataEntry template_name = 'wamtram2/entry_curation_list.html' context_object_name = 'entries' - paginate_by = 50 + paginate_by = 10 def get_queryset(self): batch_id = self.kwargs.get('batch_id') From bb5e8b7ab530570dde6f2bfafe192cf1bd27a228 Mon Sep 17 00:00:00 2001 From: Xinlyu Wang Date: Fri, 15 Nov 2024 14:22:56 +0800 Subject: [PATCH 11/34] Add inline editing functionality to entry list --- ...tch_list.html => batch_curation_list.html} | 6 +- .../wamtram2/entry_curation_list.html | 127 +++++++++++++++++- wamtram2/urls.py | 1 + wamtram2/views.py | 44 +++++- 4 files changed, 171 insertions(+), 7 deletions(-) rename wamtram2/templates/wamtram2/{entry_batch_list.html => batch_curation_list.html} (98%) diff --git a/wamtram2/templates/wamtram2/entry_batch_list.html b/wamtram2/templates/wamtram2/batch_curation_list.html similarity index 98% rename from wamtram2/templates/wamtram2/entry_batch_list.html rename to wamtram2/templates/wamtram2/batch_curation_list.html index a66094d2..c8953ce8 100644 --- a/wamtram2/templates/wamtram2/entry_batch_list.html +++ b/wamtram2/templates/wamtram2/batch_curation_list.html @@ -28,18 +28,18 @@

Batch List

-
+
{% include "includes/search_form.html" with placeholder="Search batch code, comments or entered by..." %}
-
+
{% if is_paginated %} {% include "pagination.html" %} {% endif %} diff --git a/wamtram2/templates/wamtram2/entry_curation_list.html b/wamtram2/templates/wamtram2/entry_curation_list.html index f6f6b97a..439ec99f 100644 --- a/wamtram2/templates/wamtram2/entry_curation_list.html +++ b/wamtram2/templates/wamtram2/entry_curation_list.html @@ -7,6 +7,15 @@ + {% endblock %} {% block breadcrumbs %} @@ -28,6 +37,16 @@

Entries for Batch {{ batch_id }}

+
+
+ + +
+
-
+
{% include "includes/search_form.html" with placeholder="Search comments or species..." %}
-
+
{% if is_paginated %} {% include "pagination.html" %} {% endif %} @@ -66,7 +85,13 @@

Entries for Batch {{ batch_id }}

onclick="viewEntry({{ entry.data_entry_id }})"> {% for column in all_columns %} {% if column.field in visible_columns %} - + + {% if column.field == 'data_entry_id' %} {{ entry.data_entry_id }} @@ -373,18 +398,114 @@

+ + + +

{% endblock %} {% block extra_js %} {{ block.super }}