show reports by & about a user - closes #2526 - closes #2527

This commit is contained in:
Thibault Duplessis 2017-01-15 21:07:05 +01:00
parent 883be5eb7b
commit 048b2764cd
5 changed files with 52 additions and 16 deletions

View file

@ -210,7 +210,7 @@ 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.report.api.byAndAbout(user, 20) zip
Env.pref.api.getPref(user) flatMap {
case ((((((email, spy), playerAggregateAssessment), history), charges), reports), pref) =>
(Env.playban.api bans spy.usersSharingIp.map(_.id)) map { bans =>

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], reports: List[lila.report.Report], 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: lila.report.Report.ByAndAbout, pref: lila.pref.Pref)(implicit ctx: Context)
@import lila.evaluation.Display
@import lila.pref.Pref
@ -262,17 +262,32 @@
}
</div>
<div class="reports">
<strong class="text" data-icon="!">Reports sent@if(reports.isEmpty){: nothing to show.}</strong>
@if(reports.nonEmpty) {
<ul>
@reports.map { r =>
<li>
@userIdLink(r.user.some) for @r.realReason "@shorten(r.text, 200)" @momentFromNow(r.createdAt)
</li>
<div class="half">
<strong class="text" data-icon="!">Reports sent by the user@if(reports.by.isEmpty){: nothing to show.}</strong>
@if(reports.by.nonEmpty) {
<ul>
@reports.by.map { r =>
<li>
@userIdLink(r.user.some) for @r.realReason @momentFromNow(r.createdAt) @shorten(r.text, 200)
</li>
}
</ul>
<br />
}
</ul>
<br />
}
</div>
<div class="half">
<strong class="text" data-icon="!">Reports concerning this user@if(reports.about.isEmpty){: nothing to show.}</strong>
@if(reports.about.nonEmpty) {
<ul>
@reports.about.map { r =>
<li>
@userIdLink(r.createdBy.some) for @r.realReason @momentFromNow(r.createdAt) @shorten(r.text, 200)
</li>
}
</ul>
<br />
}
</div>
</div>
<table class="others slist">
<thead>

View file

@ -61,6 +61,8 @@ object Report {
def hasIrwinNote = notes.exists(_.from == "irwin")
}
case class ByAndAbout(by: List[Report], about: List[Report])
def make(
user: User,
reason: Reason,

View file

@ -160,14 +160,16 @@ 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 byAndAbout(user: User, nb: Int): Fu[Report.ByAndAbout] = for {
by <- coll.find($doc("createdBy" -> user.id)).sort($sort.createdDesc).list[Report](nb)
about <- recent(user, nb)
} yield Report.ByAndAbout(by, about)
def recentReportersOf(user: User): Fu[List[User.ID]] =
coll.distinct[String, List]("createdBy", $doc(
"user" -> user.id,
"createdAt" -> $gt(DateTime.now minusDays 3),
"createdBy" -> $ne("lichess")
"createdAt" $gt DateTime.now.minusDays(3),
"createdBy" $ne "lichess"
).some)
def unprocessedAndRecentWithFilter(nb: Int, reason: Option[Reason]): Fu[List[Report.WithUserAndNotes]] = for {

View file

@ -419,6 +419,23 @@ div.user_show .mod_zone .plan_charges ul {
max-height: 100px;
overflow: auto;
}
div.user_show .mod_zone .reports {
display: flex;
}
div.user_show .mod_zone .reports .half {
flex: 1 1 50%;
overflow: hidden;
white-space: nowrap;
transition: 0.5s;
transition-delay: 0.3s;
}
div.user_show .mod_zone .reports .half:first-child {
margin-right: 20px;
border-right: 1px solid #ccc;
}
div.user_show .mod_zone .reports .half:hover {
flex: 0 0 90%;
}
div.user_show .evaluation time {
display: inline;
}