Skip to content

Commit

Permalink
Add gbif key field (#4234)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimasciput committed Sep 9, 2024
1 parent ba5add1 commit b7d3897
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bims/api_views/taxon_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ def create_taxon_proposal(
'hierarchical_data': {},
'gbif_data': taxon.gbif_data,
'collector_user': creator,
'additional_data': additional_data
'additional_data': additional_data,
'gbif_key': data.get('gbif_key', taxon.gbif_key)
}
)
if created:
Expand Down
1 change: 1 addition & 0 deletions bims/models/taxonomy_update_proposal.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ def approve(self, reviewer: settings.AUTH_USER_MODEL):
'biographic_distributions',
'additional_data',
'vernacular_names',
'gbif_key',
'origin']
for field in fields_to_update:
if field == 'tags':
Expand Down
6 changes: 6 additions & 0 deletions bims/static/js/taxa_management/taxa_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ export const taxaTable = (() => {
$('#apply-filters').on('click', handleFilters)
$clearSearchBtn.on('click', handleClearFilters)
$searchBtn.on('click', handleSearch)
document.getElementById("taxon-name-input").addEventListener("keydown", function(event) {
if (event.key === "Enter") {
event.preventDefault();
$searchBtn.click()
}
});
$rejectTaxonConfirmBtn.on('click', handleConfirmRejectTaxon)

$('.sort-button').on('click', handleSortButtonClicked)
Expand Down
4 changes: 4 additions & 0 deletions bims/static/js/taxa_management/taxon_detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ export const taxonDetail = (() => {
<div class="col-4"><strong>Conservation Status</strong></div>
<div class="col-8">${data.iucn_status_full_name}</div>
</div>
<div class="dt-item col-12 row">
<div class="col-4"><strong>GBIF Key</strong></div>
<div class="col-8">${data.gbif_key}</div>
</div>
</div>
</div>
</div>
Expand Down
18 changes: 18 additions & 0 deletions bims/templates/edit_taxon.html
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,20 @@ <h2>
</div>
</div>

<div class="form-group row">
<label for="gbif_key" class="col-sm-2 col-form-label col-form-label">
GBIF Key
</label>
<div class="col-sm-10">
<input type="text" name="gbif_key" id="gbif_key"
class="form-control form-control-sm"
placeholder="" value="{% if object.gbif_key %}{{ object.gbif_key }}{% endif %}" >
<small class="form-text text-muted">
<a onclick="openGbif()" href="#">Check in GBIF</a>
</small>
</div>
</div>

{% if object.accepted_taxonomy %}
<script>
acceptedTaxonomy = "{{ object.accepted_taxonomy.canonical_name }} ({{ object.accepted_taxonomy.rank }})";
Expand Down Expand Up @@ -383,6 +397,10 @@ <h2>
submitButton.disabled = true;
}
})

function openGbif() {
window.open('https://gbif.org/species/' + document.getElementById('gbif_key').value, '_blank');
}
</script>

{% endblock %}
1 change: 1 addition & 0 deletions bims/views/edit_taxon_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class EditTaxonView(LoginRequiredMixin, UserPassesTestMixin, UpdateView):
'parent',
'taxonomic_status',
'accepted_taxonomy',
'gbif_key'
]
success_url = '/taxa_management/'

Expand Down

0 comments on commit b7d3897

Please sign in to comment.