mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-09 15:05:50 +01:00
Remove currentDate from controller.
This commit is contained in:
@@ -23,7 +23,7 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
)(IssueForm.apply)
|
)(IssueForm.apply)
|
||||||
|
|
||||||
val milestoneForm = mapping(
|
val milestoneForm = mapping(
|
||||||
"title" -> trim(label("Title", text(required))),
|
"title" -> trim(label("Title", text(required, maxlength(100)))),
|
||||||
"description" -> trim(label("Description", optional(text()))),
|
"description" -> trim(label("Description", optional(text()))),
|
||||||
"dueDate" -> trim(label("Due Date", optional(date())))
|
"dueDate" -> trim(label("Due Date", optional(date())))
|
||||||
)(MilestoneForm.apply)
|
)(MilestoneForm.apply)
|
||||||
@@ -127,9 +127,7 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
getMilestone(owner, repository, milestoneId) match {
|
getMilestone(owner, repository, milestoneId) match {
|
||||||
case None => NotFound()
|
case None => NotFound()
|
||||||
case Some(m) => {
|
case Some(m) => {
|
||||||
// TODO I want to ban to use the currentDate in Controller.
|
closeMilestone(m)
|
||||||
val currentDate = new java.util.Date()
|
|
||||||
updateMilestone(m.copy(closedDate = Some(currentDate)))
|
|
||||||
redirect("/%s/%s/issues/milestones".format(owner, repository))
|
redirect("/%s/%s/issues/milestones".format(owner, repository))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,7 +141,7 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
getMilestone(owner, repository, milestoneId) match {
|
getMilestone(owner, repository, milestoneId) match {
|
||||||
case None => NotFound()
|
case None => NotFound()
|
||||||
case Some(m) => {
|
case Some(m) => {
|
||||||
updateMilestone(m.copy(closedDate = None))
|
openMilestone(m)
|
||||||
redirect("/%s/%s/issues/milestones".format(owner, repository))
|
redirect("/%s/%s/issues/milestones".format(owner, repository))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,6 +65,10 @@ trait IssuesService {
|
|||||||
milestone.dueDate,
|
milestone.dueDate,
|
||||||
milestone.closedDate)
|
milestone.closedDate)
|
||||||
|
|
||||||
|
def openMilestone(milestone: Milestone): Unit = updateMilestone(milestone.copy(closedDate = None))
|
||||||
|
|
||||||
|
def closeMilestone(milestone: Milestone): Unit = updateMilestone(milestone.copy(closedDate = Some(currentDate)))
|
||||||
|
|
||||||
def deleteMilestone(owner: String, repository: String, milestoneId: Int): Unit = {
|
def deleteMilestone(owner: String, repository: String, milestoneId: Int): Unit = {
|
||||||
Query(Issues)
|
Query(Issues)
|
||||||
.filter { i => (i.userName is owner.bind) && (i.repositoryName is repository.bind) && (i.milestoneId is milestoneId.bind)}
|
.filter { i => (i.userName is owner.bind) && (i.repositoryName is repository.bind) && (i.milestoneId is milestoneId.bind)}
|
||||||
@@ -85,11 +89,11 @@ trait IssuesService {
|
|||||||
def getMilestoneIssueCounts(owner: String, repository: String): Map[(Int, Boolean), Int] = {
|
def getMilestoneIssueCounts(owner: String, repository: String): Map[(Int, Boolean), Int] = {
|
||||||
import scala.slick.jdbc.GetResult
|
import scala.slick.jdbc.GetResult
|
||||||
|
|
||||||
case class IssueCount(userName: String, repositoryName: String, milestoneId: Int, closed: Boolean, count: Int)
|
case class IssueCount(milestoneId: Int, closed: Boolean, count: Int)
|
||||||
implicit val getIssueCount = GetResult(r => IssueCount(r.<<, r.<<, r.<<, r.<<, r.<<))
|
implicit val getIssueCount = GetResult(r => IssueCount(r.<<, r.<<, r.<<))
|
||||||
|
|
||||||
sql"""
|
sql"""
|
||||||
select USER_NAME, REPOSITORY_NAME, MILESTONE_ID, CLOSED, COUNT(ISSUE_ID)
|
select MILESTONE_ID, CLOSED, COUNT(ISSUE_ID)
|
||||||
from ISSUE
|
from ISSUE
|
||||||
where USER_NAME = $owner AND REPOSITORY_NAME = $repository AND MILESTONE_ID IS NOT NULL
|
where USER_NAME = $owner AND REPOSITORY_NAME = $repository AND MILESTONE_ID IS NOT NULL
|
||||||
group by USER_NAME, REPOSITORY_NAME, MILESTONE_ID, CLOSED"""
|
group by USER_NAME, REPOSITORY_NAME, MILESTONE_ID, CLOSED"""
|
||||||
|
|||||||
Reference in New Issue
Block a user