add post editing
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
local app = require("lapis").Application()
|
||||
local lapis_util = require("lapis.util")
|
||||
local constants = require("constants")
|
||||
|
||||
local db = require("lapis.db")
|
||||
local util = require("util")
|
||||
@ -89,23 +90,9 @@ app:get("thread", "/:slug", function(self)
|
||||
end
|
||||
|
||||
-- self.page = math.max(1, math.min(self.page, self.pages))
|
||||
local posts = db.query([[
|
||||
SELECT
|
||||
posts.id, posts.created_at, post_history.content, post_history.edited_at, users.username, users.status, avatars.file_path AS avatar_path
|
||||
FROM
|
||||
posts
|
||||
JOIN
|
||||
post_history ON posts.current_revision_id = post_history.id
|
||||
JOIN
|
||||
users ON posts.user_id = users.id
|
||||
LEFT JOIN
|
||||
avatars ON users.avatar_id = avatars.id
|
||||
WHERE
|
||||
posts.thread_id = ?
|
||||
ORDER BY
|
||||
posts.created_at ASC
|
||||
LIMIT ? OFFSET ?
|
||||
]], thread.id, POSTS_PER_PAGE, (self.page - 1) * POSTS_PER_PAGE)
|
||||
local query = (constants.FULL_POSTS_QUERY ..
|
||||
"WHERE posts.thread_id = ? ORDER BY posts.created_at ASC LIMIT ? OFFSET ?")
|
||||
local posts = db.query(query, thread.id, POSTS_PER_PAGE, (self.page - 1) * POSTS_PER_PAGE)
|
||||
self.topic = Topics:find(thread.topic_id)
|
||||
self.me = util.get_logged_in_user_or_transient(self)
|
||||
self.posts = posts
|
||||
|
Reference in New Issue
Block a user