From d67db47044edaafbaed65e32046fda865a47c07d Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Thu, 5 Apr 2018 15:44:44 +0200 Subject: [PATCH] show mod log on streamer edit page --- app/controllers/Mod.scala | 2 +- app/controllers/Streamer.scala | 9 +++++++-- app/views/streamer/edit.scala.html | 14 +++++++++++++- app/views/streamer/rules.scala.html | 2 +- modules/security/src/main/Permission.scala | 3 ++- public/stylesheets/streamer.form.css | 8 ++++---- 6 files changed, 28 insertions(+), 10 deletions(-) diff --git a/app/controllers/Mod.scala b/app/controllers/Mod.scala index 76c16a2b6e..6e57b1ec47 100644 --- a/app/controllers/Mod.scala +++ b/app/controllers/Mod.scala @@ -150,7 +150,7 @@ object Mod extends LilaController { } } - def log = Secure(_.SeeReport) { implicit ctx => me => + def log = Secure(_.ModLog) { implicit ctx => me => modLogApi.recent map { html.mod.log(_) } } diff --git a/app/controllers/Streamer.scala b/app/controllers/Streamer.scala index ddd6abbba0..af3cc0e77f 100644 --- a/app/controllers/Streamer.scala +++ b/app/controllers/Streamer.scala @@ -47,7 +47,9 @@ object Streamer extends LilaController { def edit = Auth { implicit ctx => me => AsStreamer { s => Env.streamer.liveStreamApi of s flatMap { sws => - NoCache(Ok(html.streamer.edit(sws, StreamerForm userForm sws.streamer))).fuccess + isGranted(_.ModLog).??(Env.mod.logApi.userHistory(s.user.id) map some) map { modLog => + NoCache(Ok(html.streamer.edit(sws, StreamerForm userForm sws.streamer, modLog))) + } } } } @@ -57,7 +59,10 @@ object Streamer extends LilaController { Env.streamer.liveStreamApi of s flatMap { sws => implicit val req = ctx.body StreamerForm.userForm(sws.streamer).bindFromRequest.fold( - error => BadRequest(html.streamer.edit(sws, error)).fuccess, + error => + isGranted(_.ModLog).??(Env.mod.logApi.userHistory(s.user.id) map some) map { modLog => + BadRequest(html.streamer.edit(sws, error, modLog)) + }, data => api.update(sws.streamer, data, isGranted(_.Streamers)) map { change => change.list foreach { Env.mod.logApi.streamerList(lila.report.Mod(me), s.user.id, _) } change.feature foreach { Env.mod.logApi.streamerFeature(lila.report.Mod(me), s.user.id, _) } diff --git a/app/views/streamer/edit.scala.html b/app/views/streamer/edit.scala.html index e35813ed18..56e3a7c1c6 100644 --- a/app/views/streamer/edit.scala.html +++ b/app/views/streamer/edit.scala.html @@ -1,4 +1,4 @@ -@(s: lila.streamer.Streamer.WithUserAndStream, form: Form[_])(implicit ctx: Context) +@(s: lila.streamer.Streamer.WithUserAndStream, form: Form[_], modLog: Option[List[lila.mod.Modlog]])(implicit ctx: Context) @import play.api.data.Field @@ -71,6 +71,18 @@ menu = menu("edit", s.withoutStream.some).some) { If your stream is in another language than English, include the correct language tag (2-letter ISO 639-1 code enclosed in square brackets) in your stream title. As examples, include "[RU]" for Russian, "[TR]" for Turkish, "[FR]" for French, etc. If your stream is in English, there is no need to include a language tag. } + @modLog.map { log => +
+ Moderation history@if(log.isEmpty){: nothing to show.} + @if(log.nonEmpty) { + + } +
+ }
@errMsgMaterial(form.errors) @if(isGranted(_.Streamers)) { diff --git a/app/views/streamer/rules.scala.html b/app/views/streamer/rules.scala.html index 396aa85ad2..7dc8005368 100644 --- a/app/views/streamer/rules.scala.html +++ b/app/views/streamer/rules.scala.html @@ -1,5 +1,5 @@ @() -