Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the NEST_AGE_DEFAULT from "unknown" to "fresh" #624

Merged
merged 38 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
7e081a9
Improve person manage page
RickWangPerth Nov 14, 2024
fe8452e
Add manage nesting season page
RickWangPerth Nov 14, 2024
e818d4f
Create batch curation list view
RickWangPerth Nov 14, 2024
ecb5170
Create batch curation list view
RickWangPerth Nov 14, 2024
e0bfb94
Fix batch curation list view
RickWangPerth Nov 15, 2024
3724190
Fix batch curation list view
RickWangPerth Nov 15, 2024
a1d5267
Fix batch curation list view
RickWangPerth Nov 15, 2024
b20ceb2
Create entry curation list view
RickWangPerth Nov 15, 2024
f4f82fb
Create entry curation list view
RickWangPerth Nov 15, 2024
785ff91
Fix entry curation list view
RickWangPerth Nov 15, 2024
bb5e8b7
Add inline editing functionality to entry list
RickWangPerth Nov 15, 2024
761ed7c
Fix entry curation list template
RickWangPerth Nov 15, 2024
f01055e
Fix nesting season list template
RickWangPerth Nov 15, 2024
48f0529
Fix the data input for NestingSeason admin page
RickWangPerth Nov 18, 2024
f40e6fb
Disable browser form autocomplete in data entry form
RickWangPerth Nov 18, 2024
056aa73
Enhance data curation entry grid with editable fields
RickWangPerth Nov 18, 2024
bce253f
Add custom template filter for field value access in data entry curat…
RickWangPerth Nov 18, 2024
b826dfd
Fix bug in entry curation list page
RickWangPerth Nov 19, 2024
9a0e701
Redesign the entry curation list page
RickWangPerth Nov 19, 2024
129fb34
Fix bug in entry curation list page
RickWangPerth Nov 19, 2024
2a31ab7
Add observation status indicators and edit restrictions to the entry …
RickWangPerth Nov 19, 2024
36a80c1
Add searchable fields for places and personnel
RickWangPerth Nov 19, 2024
145c72b
Adjust the entry curation list page
RickWangPerth Nov 20, 2024
b510ff9
Merge branch 'v2.9dev' into v2.9uat
RickWangPerth Nov 20, 2024
42ab599
Change the NEST_AGE_DEFAULT from "unknown" to "fresh"
RickWangPerth Nov 28, 2024
7a9a62a
Move to version 2.1.3
RickWangPerth Nov 28, 2024
365a77b
Merge branch 'master' into v2.1.3prod
RickWangPerth Nov 28, 2024
dc11050
Change the NEST_AGE_DEFAULT from "unknown" to "fresh"
RickWangPerth Nov 28, 2024
40f439d
Merge branch 'v2.1.3prod' of https://github.com/dbca-wa/wastd into v2…
RickWangPerth Nov 28, 2024
80c52cd
Test the obs test output
RickWangPerth Nov 28, 2024
1b29e06
Test the obs test output
RickWangPerth Nov 28, 2024
2ff927a
Test the obs test output
RickWangPerth Nov 28, 2024
18ae298
Test the obs test output
RickWangPerth Nov 28, 2024
a08ef1a
Test the obs test output
RickWangPerth Nov 28, 2024
8ca4ce5
Merge branch 'master' into v2.1.3prod
RickWangPerth Nov 28, 2024
1f1ac20
Update test_management_commands_auto_qa_checks.py
RickWangPerth Nov 28, 2024
a8f26be
Test the obs test output
RickWangPerth Nov 28, 2024
e0acd07
Replace NEST_AGE_DEFAULT by "unknown"
RickWangPerth Nov 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kustomize/overlays/prod/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ patches:
- path: service_patch.yaml
images:
- name: ghcr.io/dbca-wa/wastd
newTag: 2.1.1
newTag: 2.1.3

6 changes: 3 additions & 3 deletions observations/lookups.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,12 +405,12 @@
)
NESTING_PRESENT = ("nest-with-eggs", "nest-unsure-of-eggs")

NEST_AGE_DEFAULT = "unknown"
NEST_AGE_DEFAULT = "fresh"
NEST_AGE_CHOICES = (
("fresh", "Fresh, made last night"),
(NEST_AGE_DEFAULT, "Fresh, made last night"),
("missed", "Missed turtle, made within past hours"),
("old", "Old, made before last night"),
(NEST_AGE_DEFAULT, "Unknown age"),
("unknown", "Unknown age"),
)

NEST_TYPE_DEFAULT = "track-not-assessed"
Expand Down
2 changes: 1 addition & 1 deletion observations/management/commands/automated_qa_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def handle(self, *args, **options):
enc.save()

# Check: Any turtle nest encounter with uncertain nest age.
nest_encounters = TurtleNestEncounter.objects.filter(nest_age=NEST_AGE_DEFAULT, status=Encounter.STATUS_IMPORTED)
nest_encounters = TurtleNestEncounter.objects.filter(nest_age="unknown", status=Encounter.STATUS_IMPORTED)
if nest_encounters:
logger.info(f'Flagging {nest_encounters.count()} turtle nest encounters for curation due to uncertain nest age')
for enc in nest_encounters:
Expand Down
2 changes: 1 addition & 1 deletion observations/tests/test_management_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def test_flag_nests_with_uncertain_nest_age(self, mock_get_logger):
TurtleNestEncounter.objects.create(
site=self.area,
status=Encounter.STATUS_IMPORTED,
nest_age=NEST_AGE_DEFAULT,
nest_age="unknown",
species=TURTLE_SPECIES,
when=datetime.now(pytz.utc),
where=Point(0.0, 0.0)
Expand Down
39 changes: 19 additions & 20 deletions observations/tests/test_management_commands_auto_qa_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def test_flag_nests_with_uncertain_nest_age(self, mock_get_logger):
TurtleNestEncounter.objects.create(
site=self.area,
status=Encounter.STATUS_IMPORTED,
nest_age=NEST_AGE_DEFAULT,
nest_age="unknown",
species=TURTLE_SPECIES,
when=datetime.now(pytz.utc),
where=Point(0.0, 0.0)
Expand Down Expand Up @@ -258,25 +258,24 @@ def test_flag_nests_with_specific_species_in_ningaloo(self, mock_get_logger):
call_command('automated_qa_checks')
mock_logger.info.assert_any_call('Flagging 1 turtle nest encounters for curation: Dermochelys coriacea (Leatherback turtle) at Ningaloo')

# @patch('logging.getLogger')
# def test_flag_imported_nests_with_unknown_reporter(self, mock_get_logger):
# mock_logger = MagicMock()
# mock_get_logger.return_value = mock_logger

# TurtleNestEncounter.objects.create(
# site=self.area,
# status=Encounter.STATUS_IMPORTED,
# species=TURTLE_SPECIES,
# nest_age=NEST_AGE,
# nest_type=NEST_TYPE,
# reporter=self.unknown_user,
# when=datetime.now(pytz.utc),
# where=Point(0.0, 0.0)
# )

# call_command('automated_qa_checks')
# print(mock_logger.info.call_args_list)
# mock_logger.info.assert_any_call('Flagging 1 turtle nest encounters for curation due to unknown reporter')
@patch('logging.getLogger')
def test_flag_imported_nests_with_unknown_reporter(self, mock_get_logger):
mock_logger = MagicMock()
mock_get_logger.return_value = mock_logger

TurtleNestEncounter.objects.create(
site=self.area,
status=Encounter.STATUS_IMPORTED,
species=TURTLE_SPECIES,
nest_age=NEST_AGE,
nest_type=NEST_TYPE,
reporter=self.unknown_user,
when=datetime.now(pytz.utc),
where=Point(0.0, 0.0)
)

call_command('automated_qa_checks')
mock_logger.info.assert_any_call('Flagging 1 turtle nest encounters for curation due to unknown reporter')

@patch('logging.getLogger')
def test_mark_imported_nests_as_curated(self, mock_get_logger):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "wastd"
version = "2.1.1"
version = "2.1.3"

description = "Western Australian Sea Turtles Database"
authors = ["Florian Mayer <florian.mayer@dbca.wa.gov.au>", "Ashley Felton <ashley.felton@dbca.wa.gov.au>","Evan Hallein <evan.hallein@dbca.wa.gov.au>", "Rick Wang <rick.wang@dbca.wa.gov.au>"]
Expand Down
18 changes: 16 additions & 2 deletions wamtram2/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
TrtDataEntry,
TrtEntryBatches,
TrtTagOrders,
TrtNestingSeason
)
from import_export.admin import ImportExportModelAdmin
from .forms import EnterUserModelForm, TrtObservationsForm, TrtPersonsForm
from .forms import EnterUserModelForm, TrtObservationsForm, TrtPersonsForm, TrtNestingSeasonForm
from django.urls import reverse
from django.utils.html import format_html
from django.db.models import Prefetch
Expand Down Expand Up @@ -272,4 +273,17 @@ class Media:
'all': ('admin/css/custom_admin.css',)
}


@admin.register(TrtNestingSeason)
class TrtNestingSeasonAdmin(admin.ModelAdmin):
form = TrtNestingSeasonForm
list_display = ['nesting_season', 'startdate', 'enddate']
search_fields = ['nesting_season']
list_filter = ['startdate', 'enddate']
class Media:
css = {
'all': ('https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css',)
}
js = (
'https://cdn.jsdelivr.net/npm/flatpickr',
'js/admin/custom_flatpickr.js',
)
33 changes: 32 additions & 1 deletion wamtram2/forms.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
from django import forms
from easy_select2 import apply_select2
from .models import TrtPersons, TrtDataEntry, TrtTags, TrtEntryBatches, TrtPlaces, TrtPitTags, Template, TrtObservations,TrtTagStates, TrtMeasurementTypes,TrtYesNo,SEX_CHOICES
from .models import (
TrtPersons, TrtDataEntry, TrtTags,
TrtEntryBatches, TrtPlaces, TrtPitTags,
Template, TrtObservations,TrtTagStates,
TrtMeasurementTypes,TrtYesNo,SEX_CHOICES,
TrtNestingSeason
)
from django_select2.forms import ModelSelect2Widget
from django.core.validators import RegexValidator
from django.db.models import Case, When, IntegerField
from datetime import timedelta
from django.conf import settings
from django.core.exceptions import ValidationError
from django.contrib.admin import widgets




Expand Down Expand Up @@ -770,3 +778,26 @@ class TagRegisterForm(forms.Form):
field_person_id = forms.CharField(widget=forms.HiddenInput(), required=False)


class TrtNestingSeasonForm(forms.ModelForm):
class Meta:
model = TrtNestingSeason
fields = '__all__'
widgets = {
'startdate': forms.DateTimeInput(
attrs={
'class': 'form-control flatpickr-datetime',
}
),
'enddate': forms.DateTimeInput(
attrs={
'class': 'form-control flatpickr-datetime',
}
),
'nesting_season': forms.TextInput(
attrs={
'class': 'form-control'
}
),
}


103 changes: 103 additions & 0 deletions wamtram2/static/css/grid.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
.grid-container {
overflow-y: auto;
position: relative;
height: 40%;
margin: 1rem 0;
border: 1px solid #dee2e6;
border-radius: 0.25rem;
width: 100%;
}

.grid-table {
width: max-content;
min-width: 100%;
margin-bottom: 0;
color: #212529;
border-collapse: collapse;
}

.grid-table thead {
position: sticky;
top:0;
background-color: #fff;
z-index: 1;
}

.grid-table th {
background: #f8f9fa;
font-weight: 500;
border-bottom: 2px solid #dee2e6;
padding: 0.75rem;
text-align: left;
}

.grid-table td {
padding: 0.75rem;
vertical-align: top;
border-top: 1px solid #dee2e6;
white-space: nowrap;
min-width: 100px;
}

.grid-table tbody tr:hover {
background-color: rgba(0,0,0,.075);
cursor: pointer;
}

.column-selector {
margin-bottom: 1rem;
}

.column-selector .list-group-item {
display: flex;
align-items: center;
padding: 0.5rem 1rem;
}

.column-selector .list-group-item input[type="checkbox"] {
margin-right: 1rem;
}

.flagged-row {
background-color: #fff3f3;
}

@media (max-width: 768px) {
.grid-table {
font-size: 0.875rem;
}

.grid-table th,
.grid-table td {
padding: 0.5rem;
}
}

.search-container {
max-width: 400px;
margin-bottom: 1rem;
}

.context-menu {
position: fixed;
background: white;
border: 1px solid #ccc;
border-radius: 4px;
box-shadow: 0 2px 5px rgba(0,0,0,0.2);
z-index: 1000;
}

.context-menu-list {
list-style: none;
margin: 0;
padding: 0;
}

.context-menu-item {
padding: 8px 12px;
cursor: pointer;
}

.context-menu-item:hover {
background-color: #f5f5f5;
}
8 changes: 8 additions & 0 deletions wamtram2/static/js/admin/custom_flatpickr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
document.addEventListener('DOMContentLoaded', function() {
flatpickr('.flatpickr-datetime', {
enableTime: true,
dateFormat: "Y-m-d H:i",
time_24hr: true,
allowInput: true,
});
});
18 changes: 18 additions & 0 deletions wamtram2/templates/wamtram2/admin_tools.html
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,24 @@ <h3 class="tool-title">Observation Transfer</h3>
</div>
</a>
</div>


<!-- Nesting Season Management -->
<div class="col-md-4 mb-4">
<a href="{% url 'wamtram2:nesting_season_list' %}" class="text-decoration-none">
<div class="tool-card p-4 text-center">
<div class="tool-icon">
<i class="fas fa-calendar-alt"></i>
</div>
<h3 class="tool-title">Nesting Seasons</h3>
<p class="tool-description">Manage nesting season time range</p>
<button class="btn btn-primary">
<i class="fas fa-arrow-right mr-2"></i>Access Tool
</button>
</div>
</a>
</div>

</div>
</div>
{% endblock %}
Loading
Loading