everything works now

This commit is contained in:
Andreas Rumpf 2017-01-02 02:45:27 +01:00
commit 31e62f83bb
2 changed files with 19 additions and 25 deletions

View file

@ -7,10 +7,11 @@
#
#proc genThreadsList(c: var TForumData, count: var int): string =
# const queryAdmin = sql"""select id, name, views, modified from thread
# where 1 or id = ?
# order by modified desc limit ?, ?"""
# const query = sql"""select id, name, views, modified from thread
# where id in (select thread from post where author in
# (select id from person where status <> 'MODERATED'))
# (select id from person where status <> 'Moderated' or id = ?))
# order by modified desc limit ?, ?"""
# const threadId = 0
# const name = 1
@ -40,7 +41,7 @@
</div>
<div id="talk-threads">
# for row in rows(db, if c.rank >= Moderator: queryAdmin else: query,
# $((c.pageNum-1) * ThreadsPerPage), $ThreadsPerPage):
# c.userId, $((c.pageNum-1) * ThreadsPerPage), $ThreadsPerPage):
# inc(count)
<div>
<div class="topic">
@ -120,9 +121,9 @@
#proc genPostsList(c: var TForumData, threadId: string, count: var int): string =
# let query = sql("""select p.id, u.name, p.header, p.content, p.creation, p.author, u.email from post p,
# person u
# where u.id = p.author and p.thread = ? $#
# where u.id = p.author and p.thread = ? and $#
# order by p.id limit ?, ?""" %
# (if c.rank >= Moderator: "" else: "and p.status <> 'MODERATED'"))
# (if c.rank >= Moderator: "(1 or u.id = ?)" else: "(u.status <> 'Moderated' or p.author = ?)"))
# const postId = 0
# const userName = 1
# const postHeader = 2
@ -132,7 +133,7 @@
# const userEmail = 6
# result = ""
# count = 0
# let posts = getAllRows(db, query, threadId, $((c.pageNum-1) * PostsPerPage), $PostsPerPage)
# let posts = getAllRows(db, query, threadId, c.userId, $((c.pageNum-1) * PostsPerPage), $PostsPerPage)
# if posts.len < 1: return ""
# end if
<div id="talk-head">
@ -278,6 +279,8 @@
# end for
</td></select>
</tr>
</table>
<input type="submit" value="Change">
</form>
#end proc
#

View file

@ -392,9 +392,7 @@ proc getBanErrorMsg(banValue: string; rank: Rank): string =
of Inactive: return "Your account has been deactivated."
of EmailUnconfirmed:
return "You need to confirm your email first."
of Moderated:
return "Your posts await moderation."
of User, Moderator, Admin:
of Moderated, User, Moderator, Admin:
return ""
proc checkLoggedIn(c: var TForumData) =
@ -1177,7 +1175,7 @@ routes:
resp genMain(c, "Failed to delete all user's posts and threads.",
"Error - NimForum")
post "/dosetrank/?":
post "/dosetrank/?@nick?/?":
createTFD()
cond(@"nick" != "")
@ -1187,22 +1185,15 @@ routes:
var ui: TUserInfo
if not gatherUserInfo(c, @"nick", ui):
resp genMain(c, "User " & @"nick" & " does not exist.", "Error - Nim Forum")
#elif ui.
# XXX check that moderator can make themselves admins
echo(@"rank")
echo(@"reason")
when false:
let result =
if @"del" == "true":
# Remove the ban.
setBan(c, @"nick", "")
else:
setBan(c, @"nick", @"reason")
if result:
redirect(c.req.makeUri("/profile/" & @"nick"))
else:
resp genMain(c, "Failed to change the ban status of user.",
"Error - Nim Forum")
let newRank = parseEnum[Rank](@"rank")
if newRank > c.rank:
resp genMain(c, "You cannot change this user's rank to this value.", "Error - Nim Forum")
if setStatus(c, @"nick", newRank, @"reason"):
redirect(c.req.makeUri("/profile/" & @"nick"))
else:
resp genMain(c, "Failed to change the ban status of user.",
"Error - Nim Forum")
get "/setpassword/?":
createTFD()