From 49fadacb940115df5f72afece64f025973100ab7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Aug 2024 13:40:13 +0000 Subject: [PATCH 01/21] Bump docker/build-push-action from 5 to 6 Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 5 to 6. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/v5...v6) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/image-build-scan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/image-build-scan.yml b/.github/workflows/image-build-scan.yml index 16a1446b3..351306ba9 100644 --- a/.github/workflows/image-build-scan.yml +++ b/.github/workflows/image-build-scan.yml @@ -58,7 +58,7 @@ jobs: # Build and push Docker image (not on PR) #---------------------------------------------- - name: Build and push Docker image - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: context: . push: ${{ github.event_name != 'pull_request' }} From c358059736eac316ab42ddb67111b0e1c3bb44fd Mon Sep 17 00:00:00 2001 From: Xinlyu Rick Wang Date: Mon, 16 Sep 2024 12:18:51 +0800 Subject: [PATCH 02/21] Add New incident type (hauled-out) to the marine mammal incident database --- marine_mammal_incidents/models.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/marine_mammal_incidents/models.py b/marine_mammal_incidents/models.py index 2905f4341..05620dc5e 100644 --- a/marine_mammal_incidents/models.py +++ b/marine_mammal_incidents/models.py @@ -29,7 +29,9 @@ class Incident(models.Model): (ENTANGLEMENT, 'Entanglement'), (ENTRAPMENT, 'Entrapment'), (VESSEL_COLLISION, 'Vessel collision'), - (UNUSUAL_MORTALITY_EVENT, 'Unusual mortality event') + (UNUSUAL_MORTALITY_EVENT, 'Unusual mortality event'), + (HAULED_OUT, 'hauled-out (for pinnipeds)') + ] incident_type = models.CharField(max_length=50,choices=INCIDENT_TYPE_CHOICES) From 43f687bdb6cbbdd1b067d82120b9c49dac1ca4df Mon Sep 17 00:00:00 2001 From: Xinlyu Rick Wang Date: Mon, 16 Sep 2024 12:19:48 +0800 Subject: [PATCH 03/21] Add new incident type (hauled-out) to marine mammal incident database --- marine_mammal_incidents/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/marine_mammal_incidents/models.py b/marine_mammal_incidents/models.py index 05620dc5e..4cd6ce78a 100644 --- a/marine_mammal_incidents/models.py +++ b/marine_mammal_incidents/models.py @@ -30,7 +30,7 @@ class Incident(models.Model): (ENTRAPMENT, 'Entrapment'), (VESSEL_COLLISION, 'Vessel collision'), (UNUSUAL_MORTALITY_EVENT, 'Unusual mortality event'), - (HAULED_OUT, 'hauled-out (for pinnipeds)') + (HAULED_OUT, 'Hauled-out (for pinnipeds)') ] incident_type = models.CharField(max_length=50,choices=INCIDENT_TYPE_CHOICES) From 0a885682807a0f641f732c1b21689ff5b3d96173 Mon Sep 17 00:00:00 2001 From: Xinlyu Rick Wang Date: Mon, 16 Sep 2024 12:29:31 +0800 Subject: [PATCH 04/21] Add HAULED_OUT as a new incident type to Incident model --- marine_mammal_incidents/models.py | 1 + 1 file changed, 1 insertion(+) diff --git a/marine_mammal_incidents/models.py b/marine_mammal_incidents/models.py index 4cd6ce78a..95df5bced 100644 --- a/marine_mammal_incidents/models.py +++ b/marine_mammal_incidents/models.py @@ -24,6 +24,7 @@ class Incident(models.Model): ENTRAPMENT = 'Entrapment' VESSEL_COLLISION = 'Vessel collision' UNUSUAL_MORTALITY_EVENT = 'Unusual mortality event' + HAULED_OUT = 'Hauled-out' INCIDENT_TYPE_CHOICES = [ (STRANDING, 'Stranding'), (ENTANGLEMENT, 'Entanglement'), From 33f56e586c4936c5c2b6612900e4c99188dc3a53 Mon Sep 17 00:00:00 2001 From: Ashley Felton Date: Tue, 17 Sep 2024 10:51:42 +0800 Subject: [PATCH 05/21] Tweak HealthCheckMiddleware.readiness to close DB cursor. --- wastd/middleware.py | 1 + 1 file changed, 1 insertion(+) diff --git a/wastd/middleware.py b/wastd/middleware.py index 3c65cbd93..30ab20233 100644 --- a/wastd/middleware.py +++ b/wastd/middleware.py @@ -36,6 +36,7 @@ def readiness(self, request): cursor = connections["default"].cursor() cursor.execute("SELECT 1;") row = cursor.fetchone() + cursor.close() if row is None: return HttpResponseServerError("db: invalid response") except Exception as e: From 38e7a9fba1fa0f23c425559a4dd2b88c5c35f760 Mon Sep 17 00:00:00 2001 From: Xinlyu Wang Date: Wed, 25 Sep 2024 09:34:10 +0800 Subject: [PATCH 06/21] Fix Measurement/ Damange/Invalid submission issue in data entry form page --- wamtram2/forms.py | 13 +++- wamtram2/static/js/injuryHandler.js | 60 +++++++++++++------ wamtram2/static/js/measurementHandler.js | 41 +++++++++++++ wamtram2/static/js/tagToggleHandler.js | 17 ++++++ .../templates/wamtram2/trtdataentry_form.html | 43 ++++++------- wamtram2/views.py | 12 +++- 6 files changed, 146 insertions(+), 40 deletions(-) diff --git a/wamtram2/forms.py b/wamtram2/forms.py index c4388e632..2ea689f42 100644 --- a/wamtram2/forms.py +++ b/wamtram2/forms.py @@ -1,6 +1,6 @@ from django import forms from easy_select2 import apply_select2 -from .models import TrtPersons, TrtDataEntry, TrtTags, TrtEntryBatches, TrtPlaces, TrtPitTags, TrtPitTags, Template, TrtObservations,TrtPersons,TrtTagStates +from .models import TrtPersons, TrtDataEntry, TrtTags, TrtEntryBatches, TrtPlaces, TrtPitTags, Template, TrtObservations,TrtTagStates, TrtMeasurementTypes from django_select2.forms import ModelSelect2Widget @@ -260,6 +260,17 @@ def __init__(self, *args, **kwargs): 'placeholder': 'Enter name', }) + + # Filter the queryset for measurement types + filtered_measurement_types = TrtMeasurementTypes.objects.exclude( + measurement_type__in=['CCW', 'CCL NOTCH'] + ) + + for i in range(1, 7): + field_name = f'measurement_type_{i}' + self.fields[field_name].queryset = filtered_measurement_types + + # Filter the queryset for new tag fields new_tag_states = TrtTagStates.objects.filter( tag_state__in=["A1", "AE", "P_ED", "P_OK", "#", "R"] diff --git a/wamtram2/static/js/injuryHandler.js b/wamtram2/static/js/injuryHandler.js index efbe7b112..b7b1206a9 100644 --- a/wamtram2/static/js/injuryHandler.js +++ b/wamtram2/static/js/injuryHandler.js @@ -1,30 +1,23 @@ document.addEventListener('DOMContentLoaded', function() { - // const injuryCheckSelect = document.getElementById('id_injury_check'); - // if (injuryCheckSelect) { - // injuryCheckSelect.addEventListener('change', toggleInjuryDetails); - // toggleInjuryDetails(); - // } else { - // console.error('injuryCheckSelect not found: id_injury_check'); - // } - const toggleInjuryFieldsButton = document.getElementById('toggleInjuryFieldsButton'); if (toggleInjuryFieldsButton) { toggleInjuryFieldsButton.addEventListener('click', toggleInjuryFields); } else { console.error('toggleInjuryFieldsButton not found'); } -}); -// function toggleInjuryDetails() { -// const injuryCheckSelect = document.getElementById('id_injury_check'); -// const injuryDetails = document.getElementById('injuryDetails'); + const bodyPartFields = ['body_part_1', 'body_part_2', 'body_part_3', 'body_part_4']; + bodyPartFields.forEach(fieldId => { + const field = document.getElementById(fieldId); + if (field) { + field.addEventListener('change', updateBodyPartOptions); + } else { + console.error(`${fieldId} not found`); + } + }); -// if (injuryCheckSelect && injuryCheckSelect.value === 'N' || injuryCheckSelect.value === 'D') { -// injuryDetails.style.display = 'none'; -// } else { -// injuryDetails.style.display = 'block'; -// } -// } + updateBodyPartOptions(); +}); function toggleInjuryFields() { const injuryAdditionalFields = document.getElementById('injuryAdditionalFields'); @@ -40,3 +33,34 @@ function toggleInjuryFields() { toggleButtonIcon.classList.add('fa-plus'); } } + +function updateBodyPartOptions() { + const bodyPartFields = ['body_part_1', 'body_part_2', 'body_part_3', 'body_part_4']; + const selectedValues = new Set(); + + bodyPartFields.forEach(fieldId => { + const select = document.getElementById(fieldId); + if (select && select.value) { + selectedValues.add(select.value); + } + }); + + bodyPartFields.forEach(fieldId => { + const select = document.getElementById(fieldId); + if (select) { + const currentValue = select.value; + + selectedValues.delete(currentValue); + + Array.from(select.options).forEach(option => { + if (option.value && option.value !== currentValue) { + option.style.display = selectedValues.has(option.value) ? 'none' : ''; + } + }); + + if (currentValue) { + selectedValues.add(currentValue); + } + } + }); +} diff --git a/wamtram2/static/js/measurementHandler.js b/wamtram2/static/js/measurementHandler.js index e11ca1b2b..73de9e20b 100644 --- a/wamtram2/static/js/measurementHandler.js +++ b/wamtram2/static/js/measurementHandler.js @@ -76,3 +76,44 @@ function toggleCurvedCarapaceWidth() { console.error('curvedCarapaceWidth not found'); } } + +document.addEventListener('DOMContentLoaded', function() { + const measurementTypes = [ + 'measurement_type_1', 'measurement_type_2', 'measurement_type_3', + 'measurement_type_4', 'measurement_type_5', 'measurement_type_6' + ]; + + function updateMeasurementOptions() { + const selectedValues = new Set(); + + measurementTypes.forEach(id => { + const select = document.getElementById(id); + if (select.value) { + selectedValues.add(select.value); + } + }); + + measurementTypes.forEach(id => { + const select = document.getElementById(id); + const currentValue = select.value; + + selectedValues.delete(currentValue); + + Array.from(select.options).forEach(option => { + if (option.value && option.value !== currentValue) { + option.style.display = selectedValues.has(option.value) ? 'none' : ''; + } + }); + + if (currentValue) { + selectedValues.add(currentValue); + } + }); + } + + measurementTypes.forEach(id => { + document.getElementById(id).addEventListener('change', updateMeasurementOptions); + }); + + updateMeasurementOptions(); +}); diff --git a/wamtram2/static/js/tagToggleHandler.js b/wamtram2/static/js/tagToggleHandler.js index edabb2096..2330fb760 100644 --- a/wamtram2/static/js/tagToggleHandler.js +++ b/wamtram2/static/js/tagToggleHandler.js @@ -89,3 +89,20 @@ function toggleNewPITTags() { toggleBtn.innerHTML = ''; } } + +document.addEventListener('DOMContentLoaded', function() { + var flipperTagCheck = document.getElementById('id_flipper_tag_check'); + var oldFlipperTagSection = document.getElementById('oldFlipperTagSection'); + + function toggleOldFlipperTagSection() { + if (flipperTagCheck.value === 'N') { + oldFlipperTagSection.style.display = 'none'; + } else { + oldFlipperTagSection.style.display = ''; + } + } + + toggleOldFlipperTagSection(); + + flipperTagCheck.addEventListener('change', toggleOldFlipperTagSection); +}); diff --git a/wamtram2/templates/wamtram2/trtdataentry_form.html b/wamtram2/templates/wamtram2/trtdataentry_form.html index 2e6d730cc..70fe2ad10 100644 --- a/wamtram2/templates/wamtram2/trtdataentry_form.html +++ b/wamtram2/templates/wamtram2/trtdataentry_form.html @@ -116,13 +116,20 @@
{% endif %} {% csrf_token %} -{% bootstrap_form_errors form %} -{% if form.observation_id.value %} +{% comment %} {% bootstrap_form_errors form %} {% endcomment %} +
+{% if form.observation_id.value %}

Observation has aleady been submitted: view observation

-
-
{% endif %} +{% if form.errors %} +
+ {{ form.errors }} +
+{% endif %} + + +
@@ -253,7 +260,7 @@
Turtle ID: {% if form.turtle_id.value %} @@ -652,7 +659,7 @@
NEW PIT Tag(s)