Skip to content

Commit

Permalink
Merge pull request #65 from HybriD3-database/doi_filter
Browse files Browse the repository at this point in the history
Implemented DOI search function
  • Loading branch information
uthpalaherath authored Nov 22, 2024
2 parents 0ccab6e + 39d4eae commit 8b58d6f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions materials/templates/materials/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ <h5>Search for Materials</h5>
text = "Search by author's name";
$('#search_text').attr('placeholder', text);
$('#explanatory_text').text(text);
} else if (this.value == 'doi') {
text = "Search by DOI, e.g. 10.1515/ncrs-1999-0320";
$('#search_text').attr('placeholder', text);
$('#explanatory_text').text(text);
} else {
text = '';
$('#search_text').attr('placeholder', text);
Expand Down
11 changes: 9 additions & 2 deletions materials/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ class SearchFormView(generic.TemplateView):
["inorganic", "Inorganic Component"],
["author", "Author"],
["band_gap", "Band gap"],
["doi", "DOI"],
]

def get(self, request):
Expand Down Expand Up @@ -240,8 +241,14 @@ def post(self, request):
"is_experimental"
) # Get the is_experimental value

# If DOI search
if search_term == "doi":
systems = models.System.objects.filter(
dataset__reference__doi_isbn__icontains=search_text
).distinct()

# If band gap search
if (
elif (
search_term == "band_gap"
and band_gap_min is not None
and band_gap_max is not None
Expand Down Expand Up @@ -549,7 +556,7 @@ class DatasetViewSet(viewsets.ReadOnlyModelViewSet):
"primary_property__name": ["exact", "contains"],
"secondary_property__name": ["exact", "contains"],
"reference": ["exact"],
#"dimensionality": ["exact"],
# "dimensionality": ["exact"],
}
search_fields = filterset_fields

Expand Down

0 comments on commit 8b58d6f

Please sign in to comment.