display previous payments on user mod view
This commit is contained in:
parent
bc93f54af4
commit
e21b5d54b4
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue