This commit is contained in:
Dominik Picheta 2018-07-20 14:14:59 +01:00
commit 9f9d16467f
4 changed files with 16 additions and 11 deletions

View file

@ -769,7 +769,6 @@ routes:
from thread t, category c, person u
where t.isDeleted = 0 and category = c.id and
u.status <> 'Spammer' and u.status <> 'Troll' and
u.status <> 'Banned' and
u.id in (
select u.id from post p, person u
where p.author = u.id and p.thread = t.id

View file

@ -32,7 +32,8 @@ proc lastEdit*(post: Post): PostInfo =
post.history[^1]
proc isModerated*(post: Post): bool =
## Determines whether the specified thread is under moderation.
## Determines whether the specified post is under moderation
## (i.e. whether the post is invisible to ordinary users).
post.author.rank <= Moderated
proc isLikedBy*(post: Post, user: Option[User]): bool =

View file

@ -22,6 +22,7 @@ type
proc isModerated*(thread: Thread): bool =
## Determines whether the specified thread is under moderation.
## (i.e. whether the specified thread is invisible to ordinary users).
thread.author.rank <= Moderated
when defined(js):
@ -53,6 +54,8 @@ when defined(js):
##
## The rules for this are determined by the rank of the user, their
## settings (TODO), and whether the thread's creator is moderated or not.
##
## The ``user`` argument refers to the currently logged in user.
mixin isModerated
if user.isNone(): return not thread.isModerated
@ -108,20 +111,19 @@ when defined(js):
proc genThread(thread: Thread, isNew: bool, noBorder: bool): VNode =
let isOld = (getTime() - thread.creation.fromUnix).weeks > 2
let isBanned = thread.author.rank < Moderated
let isBanned = thread.author.rank.isBanned()
result = buildHtml():
tr(class=class({"no-border": noBorder, "banned": isBanned})):
td(class="thread-title"):
if thread.isLocked:
italic(class="fas fa-lock fa-xs",
title="Thread cannot be replied to")
if isBanned:
italic(class="fas fa-ban fa-xs",
title="Thread author is banned")
if thread.isModerated:
if isBanned:
italic(class="fas fa-ban fa-xs",
title="Thread author is banned")
else:
italic(class="fas fa-eye-slash fa-xs",
title="Thread is moderated")
italic(class="fas fa-eye-slash fa-xs",
title="Thread is moderated")
if thread.isSolved:
italic(class="fas fa-check-square fa-xs",
title="Thread has a solution")

View file

@ -4,10 +4,10 @@ type
# If you add more "Banned" states, be sure to modify forum's threadsQuery too.
Rank* {.pure.} = enum ## serialized as 'status'
Spammer ## spammer: every post is invisible
Troll ## troll: cannot write new posts
Banned ## A non-specific ban
Moderated ## new member: posts manually reviewed before everybody
## can see them
Troll ## troll: cannot write new posts
Banned ## A non-specific ban
EmailUnconfirmed ## member with unconfirmed email address. Their posts
## are visible, but cannot make new posts. This is so that
## when a user with existing posts changes their email,
@ -34,6 +34,9 @@ proc canPost*(rank: Rank): bool =
## Determines whether the specified rank can make new posts.
rank >= Rank.User or rank == Moderated
proc isBanned*(rank: Rank): bool =
rank in {Spammer, Troll, Banned}
when defined(js):
include karax/prelude
import karaxutils