This commit is contained in:
Lars Westermann 2019-06-12 21:44:24 +02:00
parent 5a9fa08e69
commit 94803ba805
Signed by: lars.westermann
GPG key ID: 9D417FA5BB9D5E1D
2 changed files with 54 additions and 3 deletions

View file

@ -56,6 +56,35 @@ fun Route.account() {
+"Aus Wiki importieren"
}
}
if (user.checkPermission(Permission.SCHEDULE)) {
form(action = "$prefix/account/shift", method = FormMethod.post) {
div("form-group") {
label {
htmlFor = "shift"
+"Zeitplan verschieben"
}
input(
name = "shift",
classes = "form-control",
type = InputType.number
) {
id = "shift"
placeholder = "Tage"
value = ""
min = "-1337"
max = "1337"
}
}
div("form-group") {
button(type = ButtonType.submit, classes = "form-btn btn-primary") {
+"Verschieben"
}
}
}
}
}
}
}
@ -523,4 +552,21 @@ fun Route.account() {
call.error(HttpStatusCode.Unauthorized)
}
}
post("/account/shift") {
authenticateOrRedirect(Permission.SCHEDULE) {
val shift = call.request.queryParameters["shift"]?.toIntOrNull() ?: 0
if (shift != 0 && shift in -1337..1337) {
val schedules = ScheduleRepository.all()
for (schedule in schedules) {
ScheduleRepository.update(schedule.copy(day = schedule.day + shift))
}
}
call.respondRedirect("$prefix/account")
}
}
}

View file

@ -945,7 +945,7 @@ private fun parseConstraintParam(params: Map<String, String?>) = params.map { (k
} else {
v.toIntOrNull()?.let { WorkGroupConstraint(ConstraintType.OnlyAfterTime, time = it) }
}
} else null
} else v.toIntOrNull()?.let { WorkGroupConstraint(ConstraintType.OnlyAfterTime, time = it) }
}
}
key.startsWith("constraint-only-before-time") -> {
@ -962,7 +962,7 @@ private fun parseConstraintParam(params: Map<String, String?>) = params.map { (k
} else {
v.toIntOrNull()?.let { WorkGroupConstraint(ConstraintType.OnlyBeforeTime, time = it) }
}
} else null
} else v.toIntOrNull()?.let { WorkGroupConstraint(ConstraintType.OnlyBeforeTime, time = it) }
}
}
key.startsWith("constraint-exact-time") -> {
@ -979,7 +979,7 @@ private fun parseConstraintParam(params: Map<String, String?>) = params.map { (k
} else {
v.toIntOrNull()?.let { WorkGroupConstraint(ConstraintType.ExactTime, time = it) }
}
} else null
} else v.toIntOrNull()?.let { WorkGroupConstraint(ConstraintType.ExactTime, time = it) }
}
}
key.startsWith("constraint-not-at-same-time") -> {
@ -1015,6 +1015,11 @@ private fun parseConstraintParam(params: Map<String, String?>) = params.map { (k
day = c1.day ?: c2.day,
time = c1.time ?: c2.time
)
c1.type == ConstraintType.ExactTime -> WorkGroupConstraint(
ConstraintType.ExactTime,
day = c1.day ?: c2.day,
time = c1.time ?: c2.time
)
else -> null
}
}