mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-06 13:35:50 +01:00
Add System Settings page.
This commit is contained in:
30
src/main/scala/app/SystemSettingsController.scala
Normal file
30
src/main/scala/app/SystemSettingsController.scala
Normal file
@@ -0,0 +1,30 @@
|
||||
package app
|
||||
|
||||
import service.{AccountService, SystemSettingsService}
|
||||
import SystemSettingsService._
|
||||
import util.AdminOnlyAuthenticator
|
||||
import jp.sf.amateras.scalatra.forms._
|
||||
|
||||
class SystemSettingsController extends SystemSettingsControllerBase
|
||||
with SystemSettingsService with AccountService with AdminOnlyAuthenticator
|
||||
|
||||
trait SystemSettingsControllerBase extends ControllerBase {
|
||||
self: SystemSettingsService with AccountService with AdminOnlyAuthenticator =>
|
||||
|
||||
private case class SystemSettingsForm(allowAccountRegistration: Boolean)
|
||||
|
||||
private val form = mapping(
|
||||
"allowAccountRegistration" -> trim(label("Account registration", boolean()))
|
||||
)(SystemSettingsForm.apply)
|
||||
|
||||
|
||||
get("/admin/system")(adminOnly {
|
||||
admin.html.system(loadSystemSettings())
|
||||
})
|
||||
|
||||
post("/admin/system", form)(adminOnly { form =>
|
||||
saveSystemSettings(SystemSettings(form.allowAccountRegistration))
|
||||
redirect("/admin/system")
|
||||
})
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user