user reporting history

This commit is contained in:
Thibault Duplessis 2017-01-15 20:47:35 +01:00
parent 1132c35130
commit 883be5eb7b
3 changed files with 25 additions and 8 deletions

View file

@ -210,10 +210,11 @@ object User extends LilaController {
(Env.mod.assessApi.getPlayerAggregateAssessmentWithGames(user.id)) zip
Env.mod.logApi.userHistory(user.id) zip
Env.plan.api.recentChargesOf(user) zip
Env.report.api.recentBy(user, 20) zip
Env.pref.api.getPref(user) flatMap {
case (((((email, spy), playerAggregateAssessment), history), charges), pref) =>
case ((((((email, spy), playerAggregateAssessment), history), charges), reports), pref) =>
(Env.playban.api bans spy.usersSharingIp.map(_.id)) map { bans =>
html.user.mod(user, email, spy, playerAggregateAssessment, bans, history, charges, pref)
html.user.mod(user, email, spy, playerAggregateAssessment, bans, history, charges, reports, pref)
}
}
}

View file

@ -1,4 +1,4 @@
@(u: User, email: Option[String], spy: lila.security.UserSpy, optionAggregateAssessment: Option[lila.evaluation.PlayerAggregateAssessment.WithGames], bans: Map[String, Int], history: List[lila.mod.Modlog], charges: List[lila.plan.Charge], pref: lila.pref.Pref)(implicit ctx: Context)
@(u: User, email: Option[String], spy: lila.security.UserSpy, optionAggregateAssessment: Option[lila.evaluation.PlayerAggregateAssessment.WithGames], bans: Map[String, Int], history: List[lila.mod.Modlog], charges: List[lila.plan.Charge], reports: List[lila.report.Report], pref: lila.pref.Pref)(implicit ctx: Context)
@import lila.evaluation.Display
@import lila.pref.Pref
@ -239,6 +239,17 @@
</table>
</div>
}
<div class="plan_charges">
<strong class="text" data-icon="@patronIconChar">Patron payments@if(charges.isEmpty){: none.}</strong>
@if(charges.nonEmpty) {
<ul>
@charges.map { c =>
<li>@c.cents.usd with @c.serviceName on @showDateTime(c.date)</li>
}
</ul>
<br />
}
</div>
<div class="mod_log">
<strong class="text" data-icon="!">Moderation history@if(history.isEmpty){: nothing to show.}</strong>
@if(history.nonEmpty) {
@ -250,12 +261,14 @@
<br />
}
</div>
<div class="plan_charges">
<strong class="text" data-icon="@patronIconChar">Patron payments@if(charges.isEmpty){: none.}</strong>
@if(charges.nonEmpty) {
<div class="reports">
<strong class="text" data-icon="!">Reports sent@if(reports.isEmpty){: nothing to show.}</strong>
@if(reports.nonEmpty) {
<ul>
@charges.map { c =>
<li>@c.cents.usd with @c.serviceName on @showDateTime(c.date)</li>
@reports.map { r =>
<li>
@userIdLink(r.user.some) for @r.realReason "@shorten(r.text, 200)" @momentFromNow(r.createdAt)
</li>
}
</ul>
<br />

View file

@ -160,6 +160,9 @@ final class ReportApi(
def recent(user: User, nb: Int): Fu[List[Report]] =
coll.find($doc("user" -> user.id)).sort($sort.createdDesc).list[Report](nb)
def recentBy(user: User, nb: Int): Fu[List[Report]] =
coll.find($doc("createdBy" -> user.id)).sort($sort.createdDesc).list[Report](nb)
def recentReportersOf(user: User): Fu[List[User.ID]] =
coll.distinct[String, List]("createdBy", $doc(
"user" -> user.id,