add donor star to server providers
This commit is contained in:
parent
4d1b23e94c
commit
c0ff4b0b3a
|
@ -36,7 +36,7 @@ final class Env(
|
|||
postApi = Env.forum.postApi,
|
||||
getRatingChart = Env.history.ratingChartApi.apply,
|
||||
getRanks = Env.user.cached.ranking.getAll,
|
||||
getDonated = Env.donation.api.donatedByUser) _
|
||||
isDonor = Env.donation.isDonor) _
|
||||
|
||||
system.actorOf(Props(new actor.Renderer), name = RendererName)
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ case class UserInfo(
|
|||
nbBlockers: Option[Int],
|
||||
nbPosts: Int,
|
||||
playTime: User.PlayTime,
|
||||
donated: Int) {
|
||||
donor: Boolean) {
|
||||
|
||||
def nbRated = user.count.rated
|
||||
|
||||
|
@ -46,7 +46,7 @@ object UserInfo {
|
|||
postApi: PostApi,
|
||||
getRatingChart: User => Fu[Option[String]],
|
||||
getRanks: String => Fu[Map[String, Int]],
|
||||
getDonated: String => Fu[Int])(user: User, ctx: Context): Fu[UserInfo] =
|
||||
isDonor: String => Fu[Boolean])(user: User, ctx: Context): Fu[UserInfo] =
|
||||
countUsers() zip
|
||||
getRanks(user.id) zip
|
||||
(gameCached nbPlaying user.id) zip
|
||||
|
@ -57,9 +57,9 @@ object UserInfo {
|
|||
relationApi.nbFollowers(user.id) zip
|
||||
(ctx.me ?? Granter(_.UserSpy) ?? { relationApi.nbBlockers(user.id) map (_.some) }) zip
|
||||
postApi.nbByUser(user.id) zip
|
||||
getDonated(user.id) zip
|
||||
isDonor(user.id) zip
|
||||
PlayTime(user) map {
|
||||
case (((((((((((nbUsers, ranks), nbPlaying), nbImported), crosstable), ratingChart), nbFollowing), nbFollowers), nbBlockers), nbPosts), donated), playTime) => new UserInfo(
|
||||
case (((((((((((nbUsers, ranks), nbPlaying), nbImported), crosstable), ratingChart), nbFollowing), nbFollowers), nbBlockers), nbPosts), isDonor), playTime) => new UserInfo(
|
||||
user = user,
|
||||
ranks = ranks,
|
||||
nbUsers = nbUsers,
|
||||
|
@ -73,6 +73,6 @@ object UserInfo {
|
|||
nbBlockers = nbBlockers,
|
||||
nbPosts = nbPosts,
|
||||
playTime = playTime,
|
||||
donated = donated)
|
||||
donor = isDonor)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ openGraph = Map(
|
|||
<p data-icon="E" class="honorific title"> @title</p>
|
||||
}
|
||||
}
|
||||
@if(info.donated >= 200) {
|
||||
@if(info.donor) {
|
||||
<a href="@routes.Donation.index" data-icon="t" class="honorific is-gold"> Lichess Donor</a>
|
||||
}
|
||||
@u.profile.map { p =>
|
||||
|
|
|
@ -2,6 +2,7 @@ package lila.donation
|
|||
|
||||
import com.typesafe.config.Config
|
||||
import lila.common.PimpedConfig._
|
||||
import scala.collection.JavaConversions._
|
||||
|
||||
final class Env(
|
||||
config: Config,
|
||||
|
@ -9,9 +10,14 @@ final class Env(
|
|||
|
||||
private val CollectionDonation = config getString "collection.donation"
|
||||
private val MonthlyGoal = config getInt "monthly_goal"
|
||||
private val ServerDonors = (config getStringList "server_donors").toList
|
||||
|
||||
def forms = DataForm
|
||||
|
||||
def isDonor(userId: String) =
|
||||
if (ServerDonors contains userId) fuccess(true)
|
||||
else api.donatedByUser(userId) map (_ >= 200)
|
||||
|
||||
lazy val api = new DonationApi(db(CollectionDonation), MonthlyGoal)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue