Categ.staffId
This commit is contained in:
parent
eb3ee040ad
commit
15d7b77f77
|
@ -11,7 +11,7 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
@categs.map { categ =>
|
||||
@if(categ.slug != "staff" || isGranted(_.StaffForum)) {
|
||||
@if(!categ.isStaff || isGranted(_.StaffForum)) {
|
||||
<tr>
|
||||
<td class="subject">
|
||||
<a class="category_name" href="@routes.ForumCateg.show(categ.slug)">@categ.name</a>
|
||||
|
|
|
@ -34,5 +34,5 @@
|
|||
<a class="@active.active("irwin")" href="@routes.Irwin.dashboard">Irwin dashboard</a>
|
||||
}
|
||||
@if(isGranted(_.StaffForum)) {
|
||||
<a class="@active.active("forum")" href="@routes.ForumCateg.show("staff")">Staff Forum</a>
|
||||
<a class="@active.active("forum")" href="@routes.ForumCateg.show(lila.forum.Categ.staffId)">Staff Forum</a>
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ case class Categ(
|
|||
def nbPosts(troll: Boolean): Int = troll.fold(nbPostsTroll, nbPosts)
|
||||
def lastPostId(troll: Boolean): String = troll.fold(lastPostIdTroll, lastPostId)
|
||||
|
||||
def isStaff = slug == "staff"
|
||||
def isStaff = slug == Categ.staffId
|
||||
|
||||
def isTeam = team.nonEmpty
|
||||
|
||||
|
@ -36,3 +36,7 @@ case class Categ(
|
|||
|
||||
def slug = id
|
||||
}
|
||||
|
||||
object Categ {
|
||||
val staffId = "staff"
|
||||
}
|
||||
|
|
|
@ -7,13 +7,12 @@ import org.joda.time.DateTime
|
|||
trait Granter {
|
||||
|
||||
private val TeamSlugPattern = """^team-([\w-]+)$""".r
|
||||
private val StaffSlug = "staff"
|
||||
|
||||
protected def userBelongsToTeam(teamId: String, userId: String): Fu[Boolean]
|
||||
protected def userOwnsTeam(teamId: String, userId: String): Fu[Boolean]
|
||||
|
||||
def isGrantedRead(categSlug: String)(implicit ctx: UserContext): Boolean =
|
||||
(categSlug == StaffSlug).fold(
|
||||
(categSlug == Categ.staffId).fold(
|
||||
ctx.me exists Master(Permission.StaffForum),
|
||||
true
|
||||
)
|
||||
|
@ -22,7 +21,7 @@ trait Granter {
|
|||
ctx.me.filter(isOldEnoughToForum) ?? { me =>
|
||||
if (Master(Permission.StaffForum)(me)) fuccess(true)
|
||||
else categSlug match {
|
||||
case StaffSlug => fuccess(false)
|
||||
case Categ.staffId => fuccess(false)
|
||||
case TeamSlugPattern(teamId) => userBelongsToTeam(teamId, me.id)
|
||||
case _ => fuccess(true)
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ case class Post(
|
|||
|
||||
def isTeam = categId startsWith teamSlug("")
|
||||
|
||||
def isStaff = categId == "staff"
|
||||
def isStaff = categId == Categ.staffId
|
||||
|
||||
def updatedOrCreatedAt = updatedAt | createdAt
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ private[forum] final class Recent(
|
|||
} mkString ";"
|
||||
}
|
||||
|
||||
private lazy val staffCategIds = "staff" :: publicCategIds
|
||||
private lazy val staffCategIds = Categ.staffId :: publicCategIds
|
||||
|
||||
private val cache = asyncCache.clearable(
|
||||
name = "forum.recent",
|
||||
|
|
|
@ -34,6 +34,8 @@ case class Topic(
|
|||
|
||||
def isSticky = ~sticky
|
||||
|
||||
def isStaff = categId == Categ.staffId
|
||||
|
||||
def withPost(post: Post): Topic = copy(
|
||||
nbPosts = post.troll.fold(nbPosts, nbPosts + 1),
|
||||
lastPostId = post.troll.fold(lastPostId, post.id),
|
||||
|
|
Loading…
Reference in a new issue