Fixes #181.
This commit is contained in:
parent
9ee0ddf176
commit
9f9d16467f
4 changed files with 16 additions and 11 deletions
|
|
@ -769,7 +769,6 @@ routes:
|
||||||
from thread t, category c, person u
|
from thread t, category c, person u
|
||||||
where t.isDeleted = 0 and category = c.id and
|
where t.isDeleted = 0 and category = c.id and
|
||||||
u.status <> 'Spammer' and u.status <> 'Troll' and
|
u.status <> 'Spammer' and u.status <> 'Troll' and
|
||||||
u.status <> 'Banned' and
|
|
||||||
u.id in (
|
u.id in (
|
||||||
select u.id from post p, person u
|
select u.id from post p, person u
|
||||||
where p.author = u.id and p.thread = t.id
|
where p.author = u.id and p.thread = t.id
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,8 @@ proc lastEdit*(post: Post): PostInfo =
|
||||||
post.history[^1]
|
post.history[^1]
|
||||||
|
|
||||||
proc isModerated*(post: Post): bool =
|
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
|
post.author.rank <= Moderated
|
||||||
|
|
||||||
proc isLikedBy*(post: Post, user: Option[User]): bool =
|
proc isLikedBy*(post: Post, user: Option[User]): bool =
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ type
|
||||||
|
|
||||||
proc isModerated*(thread: Thread): bool =
|
proc isModerated*(thread: Thread): bool =
|
||||||
## Determines whether the specified thread is under moderation.
|
## Determines whether the specified thread is under moderation.
|
||||||
|
## (i.e. whether the specified thread is invisible to ordinary users).
|
||||||
thread.author.rank <= Moderated
|
thread.author.rank <= Moderated
|
||||||
|
|
||||||
when defined(js):
|
when defined(js):
|
||||||
|
|
@ -53,6 +54,8 @@ when defined(js):
|
||||||
##
|
##
|
||||||
## The rules for this are determined by the rank of the user, their
|
## 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.
|
## settings (TODO), and whether the thread's creator is moderated or not.
|
||||||
|
##
|
||||||
|
## The ``user`` argument refers to the currently logged in user.
|
||||||
mixin isModerated
|
mixin isModerated
|
||||||
if user.isNone(): return not thread.isModerated
|
if user.isNone(): return not thread.isModerated
|
||||||
|
|
||||||
|
|
@ -108,20 +111,19 @@ when defined(js):
|
||||||
|
|
||||||
proc genThread(thread: Thread, isNew: bool, noBorder: bool): VNode =
|
proc genThread(thread: Thread, isNew: bool, noBorder: bool): VNode =
|
||||||
let isOld = (getTime() - thread.creation.fromUnix).weeks > 2
|
let isOld = (getTime() - thread.creation.fromUnix).weeks > 2
|
||||||
let isBanned = thread.author.rank < Moderated
|
let isBanned = thread.author.rank.isBanned()
|
||||||
result = buildHtml():
|
result = buildHtml():
|
||||||
tr(class=class({"no-border": noBorder, "banned": isBanned})):
|
tr(class=class({"no-border": noBorder, "banned": isBanned})):
|
||||||
td(class="thread-title"):
|
td(class="thread-title"):
|
||||||
if thread.isLocked:
|
if thread.isLocked:
|
||||||
italic(class="fas fa-lock fa-xs",
|
italic(class="fas fa-lock fa-xs",
|
||||||
title="Thread cannot be replied to")
|
title="Thread cannot be replied to")
|
||||||
|
if isBanned:
|
||||||
|
italic(class="fas fa-ban fa-xs",
|
||||||
|
title="Thread author is banned")
|
||||||
if thread.isModerated:
|
if thread.isModerated:
|
||||||
if isBanned:
|
italic(class="fas fa-eye-slash fa-xs",
|
||||||
italic(class="fas fa-ban fa-xs",
|
title="Thread is moderated")
|
||||||
title="Thread author is banned")
|
|
||||||
else:
|
|
||||||
italic(class="fas fa-eye-slash fa-xs",
|
|
||||||
title="Thread is moderated")
|
|
||||||
if thread.isSolved:
|
if thread.isSolved:
|
||||||
italic(class="fas fa-check-square fa-xs",
|
italic(class="fas fa-check-square fa-xs",
|
||||||
title="Thread has a solution")
|
title="Thread has a solution")
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,10 @@ type
|
||||||
# If you add more "Banned" states, be sure to modify forum's threadsQuery too.
|
# If you add more "Banned" states, be sure to modify forum's threadsQuery too.
|
||||||
Rank* {.pure.} = enum ## serialized as 'status'
|
Rank* {.pure.} = enum ## serialized as 'status'
|
||||||
Spammer ## spammer: every post is invisible
|
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
|
Moderated ## new member: posts manually reviewed before everybody
|
||||||
## can see them
|
## can see them
|
||||||
|
Troll ## troll: cannot write new posts
|
||||||
|
Banned ## A non-specific ban
|
||||||
EmailUnconfirmed ## member with unconfirmed email address. Their posts
|
EmailUnconfirmed ## member with unconfirmed email address. Their posts
|
||||||
## are visible, but cannot make new posts. This is so that
|
## are visible, but cannot make new posts. This is so that
|
||||||
## when a user with existing posts changes their email,
|
## 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.
|
## Determines whether the specified rank can make new posts.
|
||||||
rank >= Rank.User or rank == Moderated
|
rank >= Rank.User or rank == Moderated
|
||||||
|
|
||||||
|
proc isBanned*(rank: Rank): bool =
|
||||||
|
rank in {Spammer, Troll, Banned}
|
||||||
|
|
||||||
when defined(js):
|
when defined(js):
|
||||||
include karax/prelude
|
include karax/prelude
|
||||||
import karaxutils
|
import karaxutils
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue