mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-09 15:05:50 +01:00
Create java.util.Date TypeMapper. And add the currentDate method.
This commit is contained in:
@@ -38,11 +38,9 @@ trait AccountControllerBase extends ControllerBase {
|
||||
|
||||
post("/:userName/_edit", form)(ownerOnly { form =>
|
||||
val userName = params("userName")
|
||||
val currentDate = new java.sql.Timestamp(System.currentTimeMillis) // TODO make a common function to get the current timestamp.
|
||||
updateAccount(getAccountByUserName(userName).get.copy(
|
||||
mailAddress = form.mailAddress,
|
||||
url = form.url,
|
||||
updatedDate = currentDate))
|
||||
url = form.url))
|
||||
|
||||
redirect("/%s".format(userName))
|
||||
})
|
||||
|
||||
@@ -50,11 +50,11 @@ abstract class ControllerBase extends ScalatraFilter with ClientSideValidationFo
|
||||
/**
|
||||
* ValueType for the Date property.
|
||||
*/
|
||||
def date(constraints: Constraint*): SingleValueType[java.sql.Date] =
|
||||
new SingleValueType[java.sql.Date]((pattern("\\d{4}-\\d{2}-\\d{2}") +: constraints): _*){
|
||||
def convert(value: String): java.sql.Date = {
|
||||
def date(constraints: Constraint*): SingleValueType[java.util.Date] =
|
||||
new SingleValueType[java.util.Date]((pattern("\\d{4}-\\d{2}-\\d{2}") +: constraints): _*){
|
||||
def convert(value: String): java.util.Date = {
|
||||
val formatter = new java.text.SimpleDateFormat("yyyy-MM-dd")
|
||||
new java.sql.Date(formatter.parse(value).getTime)
|
||||
formatter.parse(value)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import jp.sf.amateras.scalatra.forms._
|
||||
|
||||
import service._
|
||||
import util.{WritableRepositoryAuthenticator, ReadableRepositoryAuthenticator, UsersOnlyAuthenticator}
|
||||
import java.sql.Timestamp
|
||||
|
||||
class IssuesController extends IssuesControllerBase
|
||||
with IssuesService with RepositoryService with AccountService
|
||||
@@ -16,7 +15,7 @@ trait IssuesControllerBase extends ControllerBase {
|
||||
|
||||
case class IssueForm(title: String, content: Option[String])
|
||||
|
||||
case class MilestoneForm(title: String, description: Option[String], dueDate: Option[java.sql.Date])
|
||||
case class MilestoneForm(title: String, description: Option[String], dueDate: Option[java.util.Date])
|
||||
|
||||
val form = mapping(
|
||||
"title" -> trim(label("Title", text(required))),
|
||||
@@ -128,8 +127,8 @@ trait IssuesControllerBase extends ControllerBase {
|
||||
getMilestone(owner, repository, milestoneId) match {
|
||||
case None => NotFound()
|
||||
case Some(m) => {
|
||||
// TODO make a common function to get the current timestamp.
|
||||
val currentDate = new Timestamp(System.currentTimeMillis)
|
||||
// TODO I want to ban to use the currentDate in Controller.
|
||||
val currentDate = new java.util.Date()
|
||||
updateMilestone(m.copy(closedDate = Some(currentDate)))
|
||||
redirect("/%s/%s/issues/milestones".format(owner, repository))
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@ trait UsersControllerBase extends ControllerBase { self: AccountService with Adm
|
||||
})
|
||||
|
||||
post("/admin/users/_new", newForm)(adminOnly { form =>
|
||||
// TODO make a common function to get the current timestamp.
|
||||
val currentDate = new java.sql.Timestamp(System.currentTimeMillis)
|
||||
// TODO I want to ban to use the currentDate in Controller.
|
||||
val currentDate = new java.util.Date()
|
||||
createAccount(Account(
|
||||
userName = form.userName,
|
||||
password = form.password,
|
||||
@@ -58,14 +58,11 @@ trait UsersControllerBase extends ControllerBase { self: AccountService with Adm
|
||||
|
||||
post("/admin/users/:name/_edit", editForm)(adminOnly { form =>
|
||||
val userName = params("userName")
|
||||
// TODO make a common function to get the current timestamp.
|
||||
val currentDate = new java.sql.Timestamp(System.currentTimeMillis)
|
||||
updateAccount(getAccountByUserName(userName).get.copy(
|
||||
password = form.password,
|
||||
mailAddress = form.mailAddress,
|
||||
isAdmin = form.isAdmin,
|
||||
url = form.url,
|
||||
updatedDate = currentDate))
|
||||
url = form.url))
|
||||
|
||||
redirect("/admin/users")
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user