show mod log on streamer edit page

pull/4195/merge
Thibault Duplessis 2018-04-05 15:44:44 +02:00
parent b0e573654f
commit d67db47044
6 changed files with 28 additions and 10 deletions

View File

@ -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(_) }
}

View File

@ -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, _) }

View File

@ -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) {
<strong>If your stream is in another language than English</strong>, include the correct language tag (<a class="blue" href="https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes">2-letter ISO 639-1 code</a> 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.
</div>
}
@modLog.map { log =>
<div class="mod_log status">
<strong class="text" data-icon="!">Moderation history@if(log.isEmpty){: nothing to show.}</strong>
@if(log.nonEmpty) {
<ul>
@log.map { e =>
<li>@userIdLink(e.mod.some, withTitle=false) <b>@e.showAction</b> @e.details @momentFromNow(e.date)</li>
}
</ul>
}
</div>
}
<form class="content_box_content material form" action="@routes.Streamer.edit@if(!ctx.is(s.user)){?u=@s.user.id}" method="POST">
@errMsgMaterial(form.errors)
@if(isGranted(_.Streamers)) {

View File

@ -1,5 +1,5 @@
@()
<ul>
<ul class="rules">
<li>Be listed as a lichess streamer.</li>
<li title="For example: Blitz battle on lichess.org">Get bumped up the top of the list when you stream with the keyword "lichess.org" in the stream title.</li>
<li>Notify your lichess followers when you start streaming.</li>

View File

@ -26,6 +26,7 @@ object Permission {
case object SetTitle extends Permission("ROLE_SET_TITLE", List(UserSpy))
case object SetEmail extends Permission("ROLE_SET_EMAIL", List(UserSpy))
case object SeeReport extends Permission("ROLE_SEE_REPORT")
case object ModLog extends Permission("ROLE_MOD_LOG")
case object SeeInsight extends Permission("ROLE_SEE_INSIGHT")
case object StreamConfig extends Permission("ROLE_STREAM_CONFIG")
case object PracticeConfig extends Permission("ROLE_PRACTICE_CONFIG")
@ -54,7 +55,7 @@ object Permission {
case object Hunter extends Permission("ROLE_HUNTER", List(
ViewBlurs, MarkEngine, MarkBooster, StaffForum,
UserSpy, UserEvaluate, SeeReport, SeeInsight,
UserSpy, UserEvaluate, SeeReport, ModLog, SeeInsight,
UserSearch, ModNote, RemoveRanking, ModMessage
))

View File

@ -58,15 +58,15 @@
font-size: 1.4em;
margin-bottom: 1em;
}
.streamer-new ul li,
.streamer.edit ul li {
.streamer-new .rules li,
.streamer.edit .rules li {
font-size: 1.2em;
margin: 1em 0 1em 2.2em;
line-height: 1.6em;
text-indent: -2.2em;
}
.streamer-new ul li::before,
.streamer.edit ul li::before {
.streamer-new .rules li::before,
.streamer.edit .rules li::before {
font-family: 'lichess';
content: 'E';
font-size: 1.5em;