better grant challenges, based on prefs, relations, ratings
parent
522add2a0a
commit
d1f981bee1
|
@ -49,7 +49,7 @@ object Setup extends LilaController with TheftPrevention {
|
|||
userId ?? UserRepo.named flatMap {
|
||||
case None => Ok(html.setup.friend(form, none, none, validFen)).fuccess
|
||||
case Some(user) => Env.challenge.granter(ctx.me, user, none) map {
|
||||
case Some(denied) => BadRequest(html.challenge.denied(denied))
|
||||
case Some(denied) => BadRequest(lila.challenge.ChallengeDenied.inEnglish(denied))
|
||||
case None => Ok(html.setup.friend(form, user.some, none, validFen))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
@(denied: lila.challenge.ChallengeDenied)(implicit ctx: Context)
|
||||
|
||||
@site.message(
|
||||
title = lila.challenge.ChallengeDenied.inEnglish(denied)) {
|
||||
icon = Html("j").some,
|
||||
title = trans.challengeToPlay.txt()) {
|
||||
|
||||
<p>@lila.challenge.ChallengeDenied.inEnglish(denied)</p>
|
||||
|
||||
}
|
||||
|
|
|
@ -20,11 +20,11 @@ object ChallengeDenied {
|
|||
}
|
||||
|
||||
def inEnglish(d: ChallengeDenied) = d.reason match {
|
||||
case Reason.YouAreAnon => "Please register to send challenges"
|
||||
case Reason.YouAreBlocked => s"You cannot challenge ${d.dest.titleUsername}"
|
||||
case Reason.TheyDontAcceptChallenges => s"${d.dest.titleUsername} does not accept any challenge"
|
||||
case Reason.RatingOutsideRange(perf) => s"Your ${perf.name} rating is too far from ${d.dest.titleUsername} rating"
|
||||
case Reason.FriendsOnly => s"${d.dest.titleUsername} only accepts challenges from friends"
|
||||
case Reason.YouAreAnon => "Please register to send challenges."
|
||||
case Reason.YouAreBlocked => s"You cannot challenge ${d.dest.titleUsername}."
|
||||
case Reason.TheyDontAcceptChallenges => s"${d.dest.titleUsername} does not accept any challenge."
|
||||
case Reason.RatingOutsideRange(perf) => s"Your ${perf.name} rating is too far from ${d.dest.titleUsername} rating."
|
||||
case Reason.FriendsOnly => s"${d.dest.titleUsername} only accepts challenges from friends."
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -442,8 +442,12 @@ module.exports = function(cfg, element) {
|
|||
prepareForm();
|
||||
lichess.pubsub.emit('content_loaded')();
|
||||
},
|
||||
error: function() {
|
||||
lichess.reload();
|
||||
error: function(res) {
|
||||
if (res.status == 400) {
|
||||
$startButtons.find('a.active').removeClass('active');
|
||||
alert(res.responseText);
|
||||
}
|
||||
else lichess.reload();
|
||||
}
|
||||
});
|
||||
$(this).addClass('active').siblings().removeClass('active');
|
||||
|
|
Loading…
Reference in New Issue