Issue label creation is available.

This commit is contained in:
takezoe
2013-06-24 20:53:04 +09:00
parent 8ca65091d0
commit 749a526a55
5 changed files with 74 additions and 7 deletions

View File

@@ -1,7 +1,29 @@
package app
import jp.sf.amateras.scalatra.forms._
import service._
import util.WritableRepositoryAuthenticator
class LabelsController extends LabelsControllerBase
with LabelsService with RepositoryService with AccountService with WritableRepositoryAuthenticator
trait LabelsControllerBase extends ControllerBase {
self: LabelsService with WritableRepositoryAuthenticator =>
case class LabelForm(labelName: String, color: String)
val labelForm = mapping(
"labelName" -> trim(label("Label name", text(required, maxlength(100)))),
"color" -> trim(label("Color", text(required, maxlength(7))))
)(LabelForm.apply)
post("/:owner/:repository/issues/label/new", labelForm)(writableRepository { form =>
val owner = params("owner")
val repository = params("repository")
createLabel(owner, repository, form.labelName, form.color.substring(1))
redirect("/%s/%s/issues".format(owner, repository))
})
}