annotate examples/blog/src/delete.luan @ 1726:b5baa841ea1b

fix directive
author Vadim Filimonov <fffilimonov@yandex.ru>
date Thu, 11 Aug 2022 12:40:19 +0200
parents bc40bc9aab3a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1387
bc40bc9aab3a start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 local Luan = require "luan:Luan.luan"
bc40bc9aab3a start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 local error = Luan.error
bc40bc9aab3a start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 local String = require "luan:String.luan"
bc40bc9aab3a start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 local to_number = String.to_number or error()
bc40bc9aab3a start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 local Http = require "luan:http/Http.luan"
bc40bc9aab3a start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 local Post = require "site:/lib/Post.luan"
bc40bc9aab3a start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7
bc40bc9aab3a start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8
bc40bc9aab3a start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 return function()
bc40bc9aab3a start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 local post_id = to_number(Http.request.parameters.post) or error()
bc40bc9aab3a start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 Post.delete_by_id(post_id)
bc40bc9aab3a start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 Http.response.send_redirect("/")
bc40bc9aab3a start postgres backup
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 end