display previous payments on user mod view

This commit is contained in:
Thibault Duplessis 2016-07-14 17:44:18 +02:00
parent bc93f54af4
commit e21b5d54b4
4 changed files with 32 additions and 11 deletions

View file

@ -192,10 +192,11 @@ object User extends LilaController {
(!isGranted(_.SetEmail, user) ?? UserRepo.email(user.id)) zip
(Env.security userSpy user.id) zip
(Env.mod.assessApi.getPlayerAggregateAssessmentWithGames(user.id)) zip
Env.mod.logApi.userHistory(user.id) flatMap {
case ((((email, spy), playerAggregateAssessment), history)) =>
Env.mod.logApi.userHistory(user.id) zip
Env.plan.api.recentChargesOf(user) flatMap {
case ((((email, spy), playerAggregateAssessment), history), charges) =>
(Env.playban.api bans spy.usersSharingIp.map(_.id)) map { bans =>
html.user.mod(user, email, spy, playerAggregateAssessment, bans, history)
html.user.mod(user, email, spy, playerAggregateAssessment, bans, history, charges)
}
}
}

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])(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])(implicit ctx: Context)
@import lila.evaluation.Display
@ -235,7 +235,7 @@
</div>
}
<div class="mod_log">
<strong data-icon="!"> Moderation history@if(history.isEmpty){: nothing to show.}</strong>
<strong class="text" data-icon="!">Moderation history@if(history.isEmpty){: nothing to show.}</strong>
@if(history.nonEmpty) {
<ul>
@history.map { e =>
@ -245,6 +245,17 @@
<br />
}
</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>
@if(spy.otherUsers.size == 1) {
<strong data-icon="f"> No similar user found</strong>
} else {

View file

@ -4,12 +4,18 @@ import org.joda.time.DateTime
import ornicar.scalalib.Random
case class Charge(
_id: String, // random
userId: Option[String],
stripe: Option[Charge.Stripe] = none,
payPal: Option[Charge.PayPal] = none,
cents: Cents,
date: DateTime)
_id: String, // random
userId: Option[String],
stripe: Option[Charge.Stripe] = none,
payPal: Option[Charge.PayPal] = none,
cents: Cents,
date: DateTime) {
def serviceName =
if (stripe.nonEmpty) "stripe"
else if (payPal.nonEmpty) "paypal"
else "???"
}
object Charge {

View file

@ -191,6 +191,9 @@ final class PlanApi(
def recentChargeUserIds(nb: Int): Fu[List[String]] =
chargeColl.primitive[String]($empty, sort = $doc("date" -> -1), "userId")
def recentChargesOf(user: User): Fu[List[Charge]] =
chargeColl.find($doc("userId" -> user.id)).sort($doc("date" -> -1)).list[Charge]()
private def getOrMakePlan(cents: Cents): Fu[StripePlan] =
stripeClient.getPlan(cents) getOrElse stripeClient.makePlan(cents)