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

View file

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