simplify inviting teachers to classes

pull/8786/head
Thibault Duplessis 2021-04-27 13:30:11 +02:00
parent 9e967ed9e6
commit 8b08613592
5 changed files with 4 additions and 14 deletions

View File

@ -148,11 +148,7 @@ object clas {
form3.group(
form("teachers"),
trans.clas.teachersOfTheClass(),
help = frag(
trans.clas.addLichessUsernames(),
br,
trans.clas.theyMustFirstApply()
).some
help = trans.clas.addLichessUsernames().some
)(form3.textarea(_)(rows := 4))
},
form3.actions(

View File

@ -51,7 +51,7 @@ final class ClasApi(
def update(from: Clas, data: ClasForm.ClasData): Fu[Clas] = {
val clas = data update from
userRepo.filterByRole(clas.teachers.toList, Permission.Teacher.dbKey) flatMap { filtered =>
userRepo.filterEnabled(clas.teachers.toList) flatMap { filtered =>
val checked = clas.copy(
teachers = clas.teachers.toList.filter(filtered.contains).toNel | from.teachers
)

View File

@ -1151,7 +1151,6 @@ val `classDescription` = new I18nKey("class:classDescription")
val `visibleByBothStudentsAndTeachers` = new I18nKey("class:visibleByBothStudentsAndTeachers")
val `teachersOfTheClass` = new I18nKey("class:teachersOfTheClass")
val `addLichessUsernames` = new I18nKey("class:addLichessUsernames")
val `theyMustFirstApply` = new I18nKey("class:theyMustFirstApply")
val `resetPassword` = new I18nKey("class:resetPassword")
val `makeSureToCopy` = new I18nKey("class:makeSureToCopy")
val `passwordX` = new I18nKey("class:passwordX")

View File

@ -611,12 +611,8 @@ final class UserRepo(val coll: Coll)(implicit ec: scala.concurrent.ExecutionCont
ReadPreference.secondaryPreferred
)
def filterByRole(userIds: Seq[User.ID], role: String): Fu[Set[User.ID]] =
coll.distinctEasy[String, Set](
F.id,
$inIds(userIds) ++ enabledSelect ++ $doc(F.roles -> role),
ReadPreference.secondaryPreferred
)
def filterEnabled(userIds: Seq[User.ID]): Fu[Set[User.ID]] =
coll.distinctEasy[String, Set](F.id, $inIds(userIds) ++ enabledSelect, ReadPreference.secondaryPreferred)
def userIdsWithRoles(roles: List[String]): Fu[Set[User.ID]] =
coll.distinctEasy[String, Set]("_id", $doc("roles" $in roles))

View File

@ -24,7 +24,6 @@
<string name="visibleByBothStudentsAndTeachers">Visible by both teachers and students of the class</string>
<string name="teachersOfTheClass">Teachers of the class</string>
<string name="addLichessUsernames">Add Lichess usernames to invite them as teachers. One per line.</string>
<string name="theyMustFirstApply">They must first apply to be Lichess Teachers.</string>
<string name="resetPassword">Reset password</string>
<string name="makeSureToCopy">Make sure to copy or write down the password now. You wont be able to see it again!</string>
<string name="passwordX">Password: %s</string>