From 5fbab57ec9d7b37608f7f8e4b40690850e174a54 Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Sat, 27 Jul 2013 23:22:25 +0200 Subject: [PATCH] notify moderators about new user reports --- app/templating/MessageHelper.scala | 6 +++++- app/views/base/layout.scala.html | 5 +++++ app/views/forum/layout.scala.html | 3 ++- app/views/forum/topic/form.scala.html | 8 ++++++-- app/views/report/form.scala.html | 7 ++++++- app/views/report/speech.scala.html | 10 ++++++++++ modules/report/src/main/ReportApi.scala | 6 ++---- 7 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 app/views/report/speech.scala.html diff --git a/app/templating/MessageHelper.scala b/app/templating/MessageHelper.scala index 10999a4802..bb62744cad 100644 --- a/app/templating/MessageHelper.scala +++ b/app/templating/MessageHelper.scala @@ -2,10 +2,14 @@ package lila.app package templating import lila.message.Env.{ current ⇒ messageEnv } +import lila.report.Env.{ current ⇒ reportEnv } import lila.user.Context -trait MessageHelper { +trait MessageHelper { self: SecurityHelper => def messageNbUnread(ctx: Context): Int = ctx.me.??(user ⇒ messageEnv.api.unreadIds(user.id).await.size) + + def reportNbUnprocessed(implicit ctx: Context): Int = + isGranted(_.SeeReport) ?? reportEnv.api.nbUnprocessed.await } diff --git a/app/views/base/layout.scala.html b/app/views/base/layout.scala.html index 2509bbfd43..849b735202 100644 --- a/app/views/base/layout.scala.html +++ b/app/views/base/layout.scala.html @@ -72,6 +72,11 @@ data-accept-languages="@acceptLanguages.mkString(",")"> } } } + @defining(reportNbUnprocessed) { nb => + @if(nb > 0) { + Report (@nb) + } + }
@trans.nbConnectedPlayers("?")
diff --git a/app/views/forum/layout.scala.html b/app/views/forum/layout.scala.html index f31274d0fe..ee1c65b691 100644 --- a/app/views/forum/layout.scala.html +++ b/app/views/forum/layout.scala.html @@ -1,4 +1,4 @@ -@(title: String, searchText: String = "", moreJs: Html = Html(""))(body: Html)(implicit ctx: Context) +@(title: String, searchText: String = "", goodies: Option[Html] = None, moreJs: Html = Html(""))(body: Html)(implicit ctx: Context) @moreCss = { @cssTag("forum.css") @@ -11,6 +11,7 @@ @base.layout( title = title, +goodies = goodies, moreCss = moreCss, moreJs = forumJs, active = siteMenu.forum.some) { diff --git a/app/views/forum/topic/form.scala.html b/app/views/forum/topic/form.scala.html index 1691c71785..26968028a4 100644 --- a/app/views/forum/topic/form.scala.html +++ b/app/views/forum/topic/form.scala.html @@ -1,7 +1,11 @@ @(categ: lila.forum.Categ, form: Form[_], captcha: lila.common.Captcha)(implicit ctx: Context) -@forum.layout( -title = "New forum topic") { +@goodies = { +
+@report.speech(true) +} + +@forum.layout(title = "New forum topic", goodies = goodies.some) {
  1. Forum
  2. @categ.name

  3. diff --git a/app/views/report/form.scala.html b/app/views/report/form.scala.html index 9b69075d48..78670420d6 100644 --- a/app/views/report/form.scala.html +++ b/app/views/report/form.scala.html @@ -4,7 +4,12 @@ @title = @{ "Report a user" } -@site.layout(title = title, moreCss = cssTag("report.css")) { +@goodies = { +
    +@report.speech(false) +} + +@site.layout(title = title, moreCss = cssTag("report.css"), goodies = goodies.some) {

    @title

    diff --git a/app/views/report/speech.scala.html b/app/views/report/speech.scala.html new file mode 100644 index 0000000000..1a4c95a70b --- /dev/null +++ b/app/views/report/speech.scala.html @@ -0,0 +1,10 @@ +@(link: Boolean) + +When you see someone cheating or being an ass,

    +DO NOT WRITE IT IN THE FORUM

    +But @if(link) { +fill this form +} else { +fill this form +} to inform the moderators.
    +Your report will be processed faster this way. diff --git a/modules/report/src/main/ReportApi.scala b/modules/report/src/main/ReportApi.scala index e23ac05ce7..ad8fe810e3 100644 --- a/modules/report/src/main/ReportApi.scala +++ b/modules/report/src/main/ReportApi.scala @@ -21,10 +21,8 @@ final class ReportApi { def process(id: String, by: User): Funit = $update.field(id, "processedBy", by.id) - - // def unprocessed = $find($query( - // Json.obj("processedBy" -> $exists(true)) - // ) sort $sort.createdDesc, 50) + + def nbUnprocessed = $count(Json.obj("processedBy" -> $exists(false))) def recent = $find($query.all sort $sort.createdDesc, 50) }