Allow deleting of all campaigns irrespective of status

This commit is contained in:
Kailash Nadh 2020-10-10 22:08:13 +05:30
parent 409b259fd3
commit f81d75a787
3 changed files with 2 additions and 13 deletions

View File

@ -416,13 +416,6 @@ func handleDeleteCampaign(c echo.Context) error {
fmt.Sprintf("Error fetching campaign: %s", pqErrMsg(err)))
}
// Only scheduled campaigns can be deleted.
if cm.Status != models.CampaignStatusDraft &&
cm.Status != models.CampaignStatusScheduled {
return echo.NewHTTPError(http.StatusBadRequest,
"Only campaigns that haven't been started can be deleted.")
}
if _, err := app.queries.DeleteCampaign.Exec(cm.ID); err != nil {
app.log.Printf("error deleting campaign: %v", err)
return echo.NewHTTPError(http.StatusInternalServerError,

View File

@ -177,8 +177,7 @@
<b-icon icon="cancel" size="is-small" />
</b-tooltip>
</a>
<a href="" v-if="canDelete(props.row)"
@click.prevent="$utils.confirm(`Delete '${props.row.name}'?`,
<a href="" @click.prevent="$utils.confirm(`Delete '${props.row.name}'?`,
() => deleteCampaign(props.row))">
<b-icon icon="trash-can-outline" size="is-small" />
</a>
@ -239,9 +238,6 @@ export default Vue.extend({
canResume(c) {
return c.status === 'paused';
},
canDelete(c) {
return c.status === 'draft' || c.status === 'scheduled';
},
isSheduled(c) {
return c.status === 'scheduled' || c.sendAt !== null;
},

View File

@ -586,7 +586,7 @@ WHERE id=$1;
UPDATE campaigns SET status=$2, updated_at=NOW() WHERE id = $1;
-- name: delete-campaign
DELETE FROM campaigns WHERE id=$1 AND (status = 'draft' OR status = 'scheduled');
DELETE FROM campaigns WHERE id=$1;
-- name: register-campaign-view
WITH view AS (