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

Add OCR Bulk Import Cron Tasks to Settings #528

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading