broadcast reset button - closes #5641
parent
63175f804a
commit
20f840d280
|
@ -55,6 +55,12 @@ object Relay extends LilaController {
|
|||
}
|
||||
}
|
||||
|
||||
def reset(slug: String, id: String) = Auth { implicit ctx => me =>
|
||||
OptionFuResult(env.api.byIdAndContributor(id, me)) { relay =>
|
||||
env.api.reset(relay, me) inject Redirect(showRoute(relay))
|
||||
}
|
||||
}
|
||||
|
||||
def show(slug: String, id: String) = Open { implicit ctx =>
|
||||
pageHit
|
||||
WithRelay(slug, id) { relay =>
|
||||
|
|
|
@ -21,7 +21,14 @@ object form {
|
|||
def edit(r: lila.relay.Relay, form: Form[Data])(implicit ctx: Context) =
|
||||
layout(r.name)(
|
||||
h1("Edit ", r.name),
|
||||
inner(form, routes.Relay.update(r.slug, r.id.value))
|
||||
inner(form, routes.Relay.update(r.slug, r.id.value)),
|
||||
hr,
|
||||
postForm(action := routes.Relay.reset(r.slug, r.id.value))(
|
||||
submitButton(
|
||||
cls := "button button-red confirm",
|
||||
title := "The source will need to be active in order to re-create the chapters!"
|
||||
)("Reset the broadcast")
|
||||
)
|
||||
)
|
||||
|
||||
private def layout(title: String)(body: Modifier*)(implicit ctx: Context) =
|
||||
|
|
|
@ -136,6 +136,7 @@ GET /broadcast/:slug/$id<\w{8}> controllers.Relay.show(slug: String,
|
|||
GET /broadcast/:slug/$id<\w{8}>/$chapterId<\w{8}> controllers.Relay.chapter(slug: String, id: String, chapterId: String)
|
||||
GET /broadcast/:slug/$id<\w{8}>/edit controllers.Relay.edit(slug: String, id: String)
|
||||
POST /broadcast/:slug/$id<\w{8}>/edit controllers.Relay.update(slug: String, id: String)
|
||||
POST /broadcast/:slug/$id<\w{8}>/reset controllers.Relay.reset(slug: String, id: String)
|
||||
|
||||
# Learn
|
||||
GET /learn controllers.Learn.index
|
||||
|
|
|
@ -87,6 +87,10 @@ final class RelayApi(
|
|||
} inject relay
|
||||
}
|
||||
|
||||
def reset(relay: Relay, by: User): Funit =
|
||||
studyApi.deleteAllChapters(relay.studyId, by) >>
|
||||
requestPlay(relay.id, true)
|
||||
|
||||
def getOngoing(id: Relay.Id): Fu[Option[Relay]] =
|
||||
repo.coll.find($doc("_id" -> id, "finished" -> false)).uno[Relay]
|
||||
|
||||
|
|
|
@ -700,6 +700,12 @@ final class StudyApi(
|
|||
}
|
||||
}
|
||||
|
||||
def deleteAllChapters(studyId: Study.Id, by: User) = sequenceStudy(studyId) { study =>
|
||||
Contribute(by.id, study) {
|
||||
chapterRepo deleteByStudy study
|
||||
}
|
||||
}
|
||||
|
||||
def erase(user: User) = studyRepo.allIdsByOwner(user.id) flatMap { ids =>
|
||||
chat ! lila.chat.actorApi.RemoveAll(ids.map(id => Chat.Id(id.value)))
|
||||
studyRepo.deleteByIds(ids) >>
|
||||
|
@ -725,7 +731,7 @@ final class StudyApi(
|
|||
|
||||
private def reloadChapters(study: Study) =
|
||||
chapterRepo.orderedMetadataByStudy(study.id).foreach { chapters =>
|
||||
sendTo(study.id)(_.reloadChapters(chapters))
|
||||
sendTo(study.id)(_ reloadChapters chapters)
|
||||
}
|
||||
|
||||
import ornicar.scalalib.Zero
|
||||
|
|
Loading…
Reference in New Issue