Allow deleting of all campaigns irrespective of status
This commit is contained in:
parent
409b259fd3
commit
f81d75a787
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
},
|
||||
|
|
|
@ -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 (
|
||||
|
|
Loading…
Reference in New Issue