diff --git a/boranga/components/occurrence/api.py b/boranga/components/occurrence/api.py
index 383f8605..89741785 100644
--- a/boranga/components/occurrence/api.py
+++ b/boranga/components/occurrence/api.py
@@ -132,7 +132,7 @@ def filter_queryset(self, request, queryset, view):
filter_scientific_name = request.GET.get('filter_scientific_name')
if filter_scientific_name and not filter_scientific_name.lower() == 'all':
- queryset = queryset.filter(species__taxonomy__scientific_name=filter_scientific_name)
+ queryset = queryset.filter(species__taxonomy__id=filter_scientific_name)
filter_status = request.GET.get('filter_status')
if filter_status and not filter_status.lower() == 'all':
diff --git a/boranga/components/species_and_communities/api.py b/boranga/components/species_and_communities/api.py
index f984c50f..32189293 100755
--- a/boranga/components/species_and_communities/api.py
+++ b/boranga/components/species_and_communities/api.py
@@ -240,6 +240,16 @@ def get(self, request, format=None):
return Response({"results": data_transform})
return Response()
+class GetScientificNameByGroup(views.APIView):
+ def get(self, request, format=None):
+ search_term = request.GET.get('term', '')
+ if search_term:
+ group_type_id = request.GET.get('group_type_id', '')
+ queryset = Taxonomy.objects.values_list('scientific_name', flat=True)
+ queryset = queryset.filter(scientific_name__icontains=search_term, kingdom_fk__grouptype=group_type_id).distinct().values('id', 'scientific_name')[:10]
+ queryset = [{'id': taxon['id'], 'text': taxon['scientific_name']} for taxon in queryset]
+ return Response({"results": queryset})
+
class GetCommonName(views.APIView):
def get(self, request, format=None):
group_type_id = request.GET.get('group_type_id', '')
diff --git a/boranga/frontend/boranga/src/api.js b/boranga/frontend/boranga/src/api.js
index a6fcb043..c7bf1a47 100644
--- a/boranga/frontend/boranga/src/api.js
+++ b/boranga/frontend/boranga/src/api.js
@@ -108,6 +108,7 @@ module.exports = {
species_lookup:"/api/species_lookup",
communities_lookup:"/api/communities_lookup",
scientific_name_lookup:"/api/scientific_name_lookup",
+ scientific_name_lookup_by_groupname:"/api/scientific_name_lookup_by_groupname",
//taxon_name_lookup:"/api/taxon_name_lookup",
common_name_lookup:"/api/common_name_lookup",
family_lookup:"/api/family_lookup",
diff --git a/boranga/frontend/boranga/src/components/common/occurrence_report_fauna_dashboard.vue b/boranga/frontend/boranga/src/components/common/occurrence_report_fauna_dashboard.vue
index c32e364e..61b7d61a 100644
--- a/boranga/frontend/boranga/src/components/common/occurrence_report_fauna_dashboard.vue
+++ b/boranga/frontend/boranga/src/components/common/occurrence_report_fauna_dashboard.vue
@@ -13,12 +13,12 @@
-
@@ -480,7 +480,7 @@ export default {
"data": function ( d ) {
d.filter_group_type = vm.group_type_name;
d.filter_occurrence = vm.filterORFaunaOccurrence;
- d.filter_species_scientific_name = vm.filterORFaunaScientificName;
+ d.filter_scientific_name = vm.filterORFaunaScientificName;
d.filter_submission_date_time = vm.filterORFaunaSubmissionDateTime;
d.filter_submitted_from_date = vm.filterORFaunaSubmittedFromDate;
d.filter_submitted_to_date = vm.filterORFaunaSubmittedToDate;
@@ -545,14 +545,14 @@ export default {
},
initialiseScientificNameLookup: function(){
let vm = this;
- $(vm.$refs.or_scientific_name_lookup).select2({
+ $(vm.$refs.or_scientific_name_lookup_by_groupname).select2({
minimumInputLength: 2,
- dropdownParent: $("#select_scientific_name"),
+ dropdownParent: $("#select_scientific_name_by_groupname"),
theme: 'bootstrap-5',
allowClear: true,
placeholder:"Select Scientific Name",
ajax: {
- url: api_endpoints.scientific_name_lookup,
+ url: api_endpoints.scientific_name_lookup_by_groupname,
dataType: 'json',
data: function(params) {
var query = {
@@ -576,7 +576,7 @@ export default {
sessionStorage.setItem("filterORFaunaScientificNameText",'');
}).
on("select2:open",function (e) {
- const searchField = $('[aria-controls="select2-or_scientific_name_lookup-results"]')
+ const searchField = $('[aria-controls="select2-or_scientific_name_lookup_by_groupname-results"]')
searchField[0].focus();
});
},
@@ -906,7 +906,7 @@ export default {
{
// contructor new Option(text, value, defaultSelected, selected)
var newOption = new Option(sessionStorage.getItem("filterORFaunaScientificNameText"), vm.filterORFaunaScientificName, false, true);
- $('#or_scientific_name_lookup').append(newOption);
+ $('#or_scientific_name_lookup_by_groupname').append(newOption);
}
});
}
diff --git a/boranga/frontend/boranga/src/components/common/occurrence_report_flora_dashboard.vue b/boranga/frontend/boranga/src/components/common/occurrence_report_flora_dashboard.vue
index 7bc6cb70..5b7d07e8 100644
--- a/boranga/frontend/boranga/src/components/common/occurrence_report_flora_dashboard.vue
+++ b/boranga/frontend/boranga/src/components/common/occurrence_report_flora_dashboard.vue
@@ -13,12 +13,12 @@
-
@@ -479,7 +479,7 @@ export default {
"data": function ( d ) {
d.filter_group_type = vm.group_type_name;
d.filter_occurrence = vm.filterORFloraOccurrence;
- d.filter_species_scientific_name = vm.filterORFloraScientificName;
+ d.filter_scientific_name = vm.filterORFloraScientificName;
d.filter_status = vm.filterORFloraStatus;
d.filter_submitted_from_date = vm.filterORFloraSubmittedFromDate;
d.filter_submitted_to_date = vm.filterORFloraSubmittedToDate;
@@ -544,14 +544,14 @@ export default {
},
initialiseScientificNameLookup: function(){
let vm = this;
- $(vm.$refs.or_scientific_name_lookup).select2({
+ $(vm.$refs.or_scientific_name_lookup_by_groupname).select2({
minimumInputLength: 2,
- dropdownParent: $("#select_scientific_name"),
+ dropdownParent: $("#select_scientific_name_by_groupname"),
theme: 'bootstrap-5',
allowClear: true,
placeholder:"Select Scientific Name",
ajax: {
- url: api_endpoints.scientific_name_lookup,
+ url: api_endpoints.scientific_name_lookup_by_groupname,
dataType: 'json',
data: function(params) {
var query = {
@@ -575,7 +575,7 @@ export default {
sessionStorage.setItem("filterORFloraScientificNameText",'');
}).
on("select2:open",function (e) {
- const searchField = $('[aria-controls="select2-or_scientific_name_lookup-results"]')
+ const searchField = $('[aria-controls="select2-or_scientific_name_lookup_by_groupname-results"]')
searchField[0].focus();
});
},
@@ -905,7 +905,7 @@ export default {
{
// contructor new Option(text, value, defaultSelected, selected)
var newOption = new Option(sessionStorage.getItem("filterORFloraScientificNameText"), vm.filterORFloraScientificName, false, true);
- $('#or_scientific_name_lookup').append(newOption);
+ $('#or_scientific_name_lookup_by_groupname').append(newOption);
}
});
}
diff --git a/boranga/urls.py b/boranga/urls.py
index 5f327e59..662d7020 100755
--- a/boranga/urls.py
+++ b/boranga/urls.py
@@ -114,6 +114,7 @@
url(r'^api/species_lookup$', species_communities_api.GetSpecies.as_view(), name='get-species'),
url(r'^api/communities_lookup$', species_communities_api.GetCommunities.as_view(), name='get-communities'),
url(r'^api/scientific_name_lookup$', species_communities_api.GetScientificName.as_view(), name='get-scientific-name'),
+ url(r'^api/scientific_name_lookup_by_groupname$', species_communities_api.GetScientificNameByGroup.as_view(), name='get-scientific-name-by-groupname'),
url(r'^api/common_name_lookup$', species_communities_api.GetCommonName.as_view(), name='get-common-name'),
url(r'^api/family_lookup$', species_communities_api.GetFamily.as_view(), name='get-family'),
url(r'^api/genera_lookup$', species_communities_api.GetGenera.as_view(), name='get-genera'),