Skip to content

Commit

Permalink
Merge pull request #528 from oakdbca/ocr-bulk-import
Browse files Browse the repository at this point in the history
Add OCR Bulk Import Cron Tasks to Settings
  • Loading branch information
xzzy authored Oct 16, 2024
2 parents 030c9f0 + 30911cd commit 0ba713f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@
class="bi bi-copy me-2"></i>
Copy</button>
<button type="button" class="btn btn-primary me-2"
@click.prevent="validate()"><i
:disabled="validatingSchema" @click.prevent="validate()"><span
v-if="validatingSchema"
class="spinner-border spinner-border-sm me-1" role="status"
aria-hidden="true"></span><i v-else
class="bi bi-card-checklist me-1"></i>
Validate</button>
Validat<template v-if="validatingSchema">ing</template><template v-else>e</template></button>
<a role="button" class="btn btn-primary"
:href="`/api/occurrence_report_bulk_import_schemas/${schema.id}/preview_import_file/?updated=${schema.datetime_updated}`"><i
class="bi bi-filetype-xlsx me-1"></i> Preview</a>
Expand Down Expand Up @@ -450,21 +453,21 @@
<template v-if="schema.can_user_edit && selectedColumn.is_editable_by_user">
<button
v-if="selectedColumn.django_import_content_type && selectedColumn.django_import_field_name"
class="btn btn-primary btn-sm me-2" @click.prevent="save()"><i
class="btn btn-primary btn-sm me-2" @click.prevent="save()" :disabled="saving"><i
class="bi bi-floppy-fill me-1"></i>
Save
Column <template v-if="saving"><span
class="spinner-border spinner-border-sm ms-2" role="status"
aria-hidden="true"></span>
<span class="visually-hidden">Loading...</span></template></button>
<button class="btn btn-danger btn-sm" v-if="!selectedColumn.id"
@click.prevent="cancelAddingColumn(selectedColumn)"><i
@click.prevent="cancelAddingColumn(selectedColumn)" :disabled="saving"><i
class="bi bi-x-circle-fill me-1"></i>
Cancel
Adding
Column</button>
<button v-else-if="selectedColumn.order != 0" class="btn btn-danger btn-sm"
@click.prevent="removeColumn(selectedColumn)"><i
@click.prevent="removeColumn(selectedColumn)" :disabled="saving"><i
class="bi bi-trash3-fill me-1"></i>
Delete
Column</button>
Expand Down Expand Up @@ -497,12 +500,12 @@
</div>
</div>
<div v-if="schema.can_user_edit" class="col-md-6 text-end"><button
class="btn btn-primary me-2 float-end" @click.prevent="save()">Save
class="btn btn-primary me-2 float-end" @click.prevent="save()" :disabled="saving">Save
and
Continue <template v-if="saving"><span class="spinner-border spinner-border-sm ms-2"
role="status" aria-hidden="true"></span>
<span class="visually-hidden">Loading...</span></template></button><button
class="btn btn-primary me-2 float-end" @click.prevent="saveAndExit()">Save and Exit
class="btn btn-primary me-2 float-end" @click.prevent="saveAndExit()" :disabled="saving">Save and Exit
<template v-if="saving"><span class="spinner-border spinner-border-sm ms-2" role="status"
aria-hidden="true"></span>
<span class="visually-hidden">Loading...</span>
Expand Down Expand Up @@ -536,7 +539,7 @@
choice[1] }}</template>
<template v-else>{{
choice[0]
}}</template>
}}</template>
</td>
</tr>
</tbody>
Expand Down Expand Up @@ -580,6 +583,7 @@ export default {
showDjangoImportFieldSelect: false,
newColumn: null,
saving: false,
validatingSchema: false,
errors: null
}
},
Expand Down Expand Up @@ -804,7 +808,7 @@ export default {
// Remove columns that are already in the schema
newColumns = newColumns.filter(newColumn => !this.schema.columns.some(column => column.django_import_field_name == newColumn.django_import_field_name))
if(newColumns.length == 0) {
if (newColumns.length == 0) {
swal.fire({
title: 'No New Columns Added',
text: 'All fields from the selected model are already in the schema',
Expand All @@ -821,7 +825,7 @@ export default {
newColumns = newColumns.filter(column => !column.xlsx_data_validation_allow_blank)
}
if(newColumns.length == 0) {
if (newColumns.length == 0) {
swal.fire({
title: 'No New Columns Added',
text: 'There are no mandatory fields from the selected model that are not already in the schema',
Expand All @@ -841,7 +845,7 @@ export default {
this.addEditMode = false
let lastColumnIndex = this.schema.columns.length;
if(this.schema.columns.filter(column => column.django_import_content_type == selectedContentType).length > 0) {
if (this.schema.columns.filter(column => column.django_import_content_type == selectedContentType).length > 0) {
let lastColumn = this.schema.columns.findLast(column => column.django_import_content_type == selectedContentType)
lastColumnIndex = this.schema.columns.indexOf(lastColumn) + 1
}
Expand Down Expand Up @@ -947,6 +951,7 @@ export default {
this.save();
},
validate() {
this.validatingSchema = true;
this.$http.get(`${api_endpoints.occurrence_report_bulk_import_schemas}${this.schema.id}/validate/`)
.then(response => {
swal.fire({
Expand Down Expand Up @@ -983,6 +988,9 @@ export default {
}
})
})
.finally(() => {
this.validatingSchema = false;
})
},
save() {
// If there is a column with no django_import_content_type or django_import_field_name, remove it
Expand Down
2 changes: 2 additions & 0 deletions boranga/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ def show_toolbar(request):
CRON_CLASSES = [
"appmonitor_client.cron.CronJobAppMonitorClient",
"boranga.cron.CronJobFetchNomosTaxonDataDaily",
"boranga.cron.CronJobOCRPreProcessBulkImportTasks",
"boranga.cron.CronJobOCRProcessBulkImportQueue",
]


Expand Down

0 comments on commit 0ba713f

Please sign in to comment.