fix delete check

This commit is contained in:
wh1te909
2020-05-29 19:59:15 +00:00
parent 724935eaa0
commit ca8819e950
2 changed files with 11 additions and 7 deletions

View File

@@ -67,6 +67,11 @@ class GetUpdateDeleteCheck(APIView):
return Response(f"{obj.readable_desc} was edited!") return Response(f"{obj.readable_desc} was edited!")
def delete(self, request, pk):
check = get_object_or_404(Check, pk=pk)
check.delete()
return Response(f"{check.readable_desc} was deleted!")
@api_view() @api_view()
def get_scripts(request): def get_scripts(request):

View File

@@ -98,7 +98,7 @@
<q-item <q-item
clickable clickable
v-close-popup v-close-popup
@click="deleteCheck(props.row.id, props.row.check_type)" @click="deleteCheck(props.row.id, props.row.readable_desc)"
> >
<q-item-section side> <q-item-section side>
<q-icon name="delete" /> <q-icon name="delete" />
@@ -439,24 +439,23 @@ export default {
return false; return false;
} }
}, },
deleteCheck(pk, check_type) { deleteCheck(pk, desc) {
this.$q this.$q
.dialog({ .dialog({
title: "Are you sure?", title: "Are you sure?",
message: `Delete ${check_type} check`, message: `Delete ${desc}`,
cancel: true, cancel: true,
persistent: true persistent: true
}) })
.onOk(() => { .onOk(() => {
const data = { pk: pk, checktype: check_type };
axios axios
.delete("checks/deletestandardcheck/", { data: data }) .delete(`/checks/${pk}/check/`)
.then(r => { .then(r => {
this.$store.dispatch("loadChecks", this.selectedAgentPk); this.$store.dispatch("loadChecks", this.selectedAgentPk);
this.$store.dispatch("loadAutomatedTasks", this.selectedAgentPk); this.$store.dispatch("loadAutomatedTasks", this.selectedAgentPk);
this.notifySuccess("Check was deleted!"); this.notifySuccess(r.data);
}) })
.catch(e => this.notifyError(e.response.data.error)); .catch(e => this.notifyError(e.response.data));
}); });
} }
}, },