official broadcasts
This commit is contained in:
parent
f47d31ba6c
commit
778e96093f
|
@ -45,7 +45,7 @@ object Relay extends LilaController {
|
|||
implicit val req = ctx.body
|
||||
env.forms.edit(relay).bindFromRequest.fold(
|
||||
err => BadRequest(html.relay.edit(relay, err)).fuccess,
|
||||
data => env.api.update(relay)(data.update) map { r => Redirect(showRoute(r)) }
|
||||
data => env.api.update(relay) { data.update(_, me) } map { r => Redirect(showRoute(r)) }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,14 +8,21 @@
|
|||
<textarea class="description" name="@field.name" id="@field.id" style="height: 7em" required>@field.value</textarea>
|
||||
}
|
||||
}
|
||||
@base.form.group(form("startsAt"), Html("Start date <strong>UTC</strong>"), help = Html("Optional, if you know when the event starts").some) {
|
||||
@base.form.flatpickr(form("startsAt"))
|
||||
|
||||
@if(isGranted(_.ModNote)) {
|
||||
@base.form.group(form("official"), Html("Official lichess broadcast")) {
|
||||
@base.form.input(form("official"), typ = "checkbox", required = true)
|
||||
<input type="checkbox" name="@form("official")" checked="@form("official").value" value="true" />
|
||||
}
|
||||
} else { <input type="hidden" name="@form("official")" value="false" /> }
|
||||
@base.form.group(form("syncUrl"), Html("Source URL")) {
|
||||
@base.form.input(form("syncUrl"), typ = "url", required = true)
|
||||
}
|
||||
@base.form.group(form("syncType"), Html("Source format")) {
|
||||
@base.form.select(form("syncType"), lila.relay.RelayForm.syncTypes)
|
||||
}
|
||||
@base.form.group(form("syncUrl"), Html("Source URL")) {
|
||||
@base.form.input(form("syncUrl"), typ = "url", required = true)
|
||||
@base.form.group(form("startsAt"), Html("Start date <strong>UTC</strong>"), help = Html("Optional, if you know when the event starts").some) {
|
||||
@base.form.flatpickr(form("startsAt"))
|
||||
}
|
||||
|
||||
@base.form.submit()
|
||||
|
|
|
@ -19,6 +19,7 @@ case class Relay(
|
|||
/* at least it *looks* finished... but maybe it's not
|
||||
* sync.nextAt is used for actually synchronising */
|
||||
finished: Boolean,
|
||||
official: Boolean,
|
||||
createdAt: DateTime
|
||||
) {
|
||||
|
||||
|
|
|
@ -32,8 +32,8 @@ final class RelayApi(
|
|||
}
|
||||
|
||||
def all(me: Option[User]): Fu[Relay.Selection] =
|
||||
created.flatMap(withStudyAndLiked(me)) zip
|
||||
started.flatMap(withStudyAndLiked(me)) zip
|
||||
scheduled.flatMap(withStudyAndLiked(me)) zip
|
||||
ongoing.flatMap(withStudyAndLiked(me)) zip
|
||||
finished.flatMap(withStudyAndLiked(me)) map {
|
||||
case c ~ s ~ t => Relay.Selection(c, s, t)
|
||||
}
|
||||
|
@ -46,21 +46,33 @@ final class RelayApi(
|
|||
def setLikes(id: Relay.Id, likes: lila.study.Study.Likes): Funit =
|
||||
coll.updateField($id(id), "likes", likes).void
|
||||
|
||||
def created = coll.find($doc(
|
||||
"startsAt" $gt DateTime.now.minusHours(1),
|
||||
"startedAt" $exists false
|
||||
def scheduled = coll.find($doc(
|
||||
selectors.scheduled ++ $doc("official" -> true)
|
||||
)).sort($sort asc "startsAt").list[Relay]()
|
||||
|
||||
def started = coll.find($doc(
|
||||
"startedAt" $exists true,
|
||||
"finished" -> false
|
||||
def ongoing = coll.find($doc(
|
||||
selectors.ongoing ++ $doc("official" -> true)
|
||||
)).sort($sort asc "startedAt").list[Relay]()
|
||||
|
||||
def finished = coll.find($doc(
|
||||
"startedAt" $exists true,
|
||||
"finished" -> true
|
||||
selectors.finished ++ $doc("official" -> true)
|
||||
)).sort($sort desc "startedAt").list[Relay]()
|
||||
|
||||
object selectors {
|
||||
def scheduled = $doc(
|
||||
"startsAt" $gt DateTime.now.minusHours(1),
|
||||
"startedAt" $exists false
|
||||
)
|
||||
def ongoing = $doc(
|
||||
"startedAt" $exists true,
|
||||
"finished" -> false
|
||||
)
|
||||
def finished = $doc(
|
||||
"startedAt" $exists true,
|
||||
"finished" -> true
|
||||
)
|
||||
}
|
||||
|
||||
def create(data: RelayForm.Data, user: User): Fu[Relay] = {
|
||||
val relay = data make user
|
||||
coll.insert(relay) >>
|
||||
|
|
|
@ -6,6 +6,7 @@ import play.api.data.Forms._
|
|||
import play.api.data.validation.Constraints._
|
||||
|
||||
import lila.user.User
|
||||
import lila.security.Granter
|
||||
|
||||
object RelayForm {
|
||||
|
||||
|
@ -19,6 +20,7 @@ object RelayForm {
|
|||
val form = Form(mapping(
|
||||
"name" -> nonEmptyText(minLength = 3, maxLength = 80),
|
||||
"description" -> nonEmptyText(minLength = 3, maxLength = 4000),
|
||||
"official" -> boolean,
|
||||
"syncType" -> text.verifying(syncTypes.map(_._1).contains _),
|
||||
"syncUrl" -> nonEmptyText,
|
||||
"startsAt" -> optional(utcDate)
|
||||
|
@ -31,6 +33,7 @@ object RelayForm {
|
|||
case class Data(
|
||||
name: String,
|
||||
description: String,
|
||||
official: Boolean,
|
||||
syncType: String,
|
||||
syncUrl: String,
|
||||
startsAt: Option[DateTime]
|
||||
|
@ -42,9 +45,10 @@ object RelayForm {
|
|||
else trimmed
|
||||
}
|
||||
|
||||
def update(relay: Relay) = relay.copy(
|
||||
def update(relay: Relay, user: User) = relay.copy(
|
||||
name = name,
|
||||
description = description,
|
||||
official = official && Granter(_.Relay)(user),
|
||||
sync = makeSync,
|
||||
startsAt = startsAt
|
||||
)
|
||||
|
@ -69,6 +73,7 @@ object RelayForm {
|
|||
likes = lila.study.Study.Likes(1),
|
||||
createdAt = DateTime.now,
|
||||
finished = false,
|
||||
official = official && Granter(_.Relay)(user),
|
||||
startsAt = startsAt,
|
||||
startedAt = none
|
||||
)
|
||||
|
@ -79,6 +84,7 @@ object RelayForm {
|
|||
def make(relay: Relay) = Data(
|
||||
name = relay.name,
|
||||
description = relay.description,
|
||||
official = relay.official,
|
||||
syncType = relay.sync.upstream.key,
|
||||
syncUrl = relay.sync.upstream.url,
|
||||
startsAt = relay.startsAt
|
||||
|
|
|
@ -48,6 +48,7 @@ object Permission {
|
|||
case object Impersonate extends Permission("ROLE_IMPERSONATE")
|
||||
case object DisapproveCoachReview extends Permission("ROLE_DISAPPROVE_COACH_REVIEW")
|
||||
case object PayPal extends Permission("ROLE_PAYPAL")
|
||||
case object Relay extends Permission("ROLE_RELAY")
|
||||
|
||||
case object Hunter extends Permission("ROLE_HUNTER", List(
|
||||
ViewBlurs, MarkEngine, MarkBooster, StaffForum,
|
||||
|
@ -59,7 +60,8 @@ object Permission {
|
|||
Hunter, ModerateForum, IpBan, CloseAccount, ReopenAccount, ViewPrivateComms,
|
||||
ChatTimeout, MarkTroll, SetTitle, SetEmail, ModerateQa, StreamConfig,
|
||||
MessageAnyone, CloseTeam, TerminateTournament, ManageTournament, ManageEvent,
|
||||
PreviewCoach, PracticeConfig, RemoveRanking, ReportBan, Beta, DisapproveCoachReview
|
||||
PreviewCoach, PracticeConfig, RemoveRanking, ReportBan, Beta, DisapproveCoachReview,
|
||||
Relay
|
||||
))
|
||||
|
||||
case object SuperAdmin extends Permission("ROLE_SUPER_ADMIN", List(
|
||||
|
|
Loading…
Reference in a new issue