Mercurial Hosting > freedit
comparison src/lib/Post.luan @ 16:bff178656073
delete function
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 06 Jul 2022 22:42:42 -0600 |
parents | de0cbf515ef5 |
children | 94e26bffd4fb |
comparison
equal
deleted
inserted
replaced
15:0edde02b908c | 16:bff178656073 |
---|---|
17 id = doc.id | 17 id = doc.id |
18 content = doc.content | 18 content = doc.content |
19 date = doc.date | 19 date = doc.date |
20 author_name = doc.post_author_name | 20 author_name = doc.post_author_name |
21 root_id = doc.post_root_id | 21 root_id = doc.post_root_id |
22 is_deleted = doc.is_deleted == "true" | |
22 | 23 |
23 -- root only | 24 -- root only |
24 subject = doc.subject | 25 subject = doc.subject |
25 is_root = doc.post_is_root == "true" | 26 is_root = doc.post_is_root == "true" |
26 | 27 |
35 id = post.id | 36 id = post.id |
36 content = post.content or error() | 37 content = post.content or error() |
37 date = post.date or time_now() | 38 date = post.date or time_now() |
38 post_author_name = post.author_name or error() | 39 post_author_name = post.author_name or error() |
39 post_root_id = post.root_id | 40 post_root_id = post.root_id |
41 is_deleted = post.is_deleted and "true" or nil | |
40 | 42 |
41 -- root only | 43 -- root only |
42 subject = post.subject | 44 subject = post.subject |
43 post_is_root = post.is_root and "true" or nil | 45 post_is_root = post.is_root and "true" or nil |
44 | 46 |
81 post.save() | 83 post.save() |
82 return post | 84 return post |
83 end ) | 85 end ) |
84 end | 86 end |
85 | 87 |
88 function post.author_is_current() | |
89 local User = require "site:/lib/User.luan" | |
90 local user = User.current() | |
91 return user ~= nil and user.name == post.author_name | |
92 end | |
93 | |
86 set_metatable(post,metatable) | 94 set_metatable(post,metatable) |
87 return post | 95 return post |
88 end | 96 end |
89 | 97 |
90 function Post.get_by_id(id) | 98 function Post.get_by_id(id) |