Allow deleting of all campaigns irrespective of status
This commit is contained in:
parent
409b259fd3
commit
f81d75a787
3 changed files with 2 additions and 13 deletions
|
@ -416,13 +416,6 @@ func handleDeleteCampaign(c echo.Context) error {
|
||||||
fmt.Sprintf("Error fetching campaign: %s", pqErrMsg(err)))
|
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 {
|
if _, err := app.queries.DeleteCampaign.Exec(cm.ID); err != nil {
|
||||||
app.log.Printf("error deleting campaign: %v", err)
|
app.log.Printf("error deleting campaign: %v", err)
|
||||||
return echo.NewHTTPError(http.StatusInternalServerError,
|
return echo.NewHTTPError(http.StatusInternalServerError,
|
||||||
|
|
|
@ -177,8 +177,7 @@
|
||||||
<b-icon icon="cancel" size="is-small" />
|
<b-icon icon="cancel" size="is-small" />
|
||||||
</b-tooltip>
|
</b-tooltip>
|
||||||
</a>
|
</a>
|
||||||
<a href="" v-if="canDelete(props.row)"
|
<a href="" @click.prevent="$utils.confirm(`Delete '${props.row.name}'?`,
|
||||||
@click.prevent="$utils.confirm(`Delete '${props.row.name}'?`,
|
|
||||||
() => deleteCampaign(props.row))">
|
() => deleteCampaign(props.row))">
|
||||||
<b-icon icon="trash-can-outline" size="is-small" />
|
<b-icon icon="trash-can-outline" size="is-small" />
|
||||||
</a>
|
</a>
|
||||||
|
@ -239,9 +238,6 @@ export default Vue.extend({
|
||||||
canResume(c) {
|
canResume(c) {
|
||||||
return c.status === 'paused';
|
return c.status === 'paused';
|
||||||
},
|
},
|
||||||
canDelete(c) {
|
|
||||||
return c.status === 'draft' || c.status === 'scheduled';
|
|
||||||
},
|
|
||||||
isSheduled(c) {
|
isSheduled(c) {
|
||||||
return c.status === 'scheduled' || c.sendAt !== null;
|
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;
|
UPDATE campaigns SET status=$2, updated_at=NOW() WHERE id = $1;
|
||||||
|
|
||||||
-- name: delete-campaign
|
-- 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
|
-- name: register-campaign-view
|
||||||
WITH view AS (
|
WITH view AS (
|
||||||
|
|
Loading…
Reference in a new issue