mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-05 04:56:02 +01:00
Merge branch 'master' of https://github.com/takezoe/gitbucket.git
This commit is contained in:
@@ -1,11 +1,22 @@
|
|||||||
package app
|
package app
|
||||||
|
|
||||||
|
import jp.sf.amateras.scalatra.forms._
|
||||||
|
|
||||||
import service._
|
import service._
|
||||||
|
import util.UsersOnlyAuthenticator
|
||||||
|
|
||||||
class IssuesController extends IssuesControllerBase
|
class IssuesController extends IssuesControllerBase
|
||||||
with RepositoryService with AccountService
|
with IssuesService with RepositoryService with AccountService with UsersOnlyAuthenticator
|
||||||
|
|
||||||
trait IssuesControllerBase extends ControllerBase { self: RepositoryService =>
|
trait IssuesControllerBase extends ControllerBase {
|
||||||
|
self: IssuesService with RepositoryService with UsersOnlyAuthenticator =>
|
||||||
|
|
||||||
|
case class IssueForm(title: String, content: Option[String])
|
||||||
|
|
||||||
|
val form = mapping(
|
||||||
|
"title" -> trim(label("Title", text(required))),
|
||||||
|
"content" -> trim(optional(text()))
|
||||||
|
)(IssueForm.apply)
|
||||||
|
|
||||||
get("/:owner/:repository/issues"){
|
get("/:owner/:repository/issues"){
|
||||||
issues.html.issues(getRepository(params("owner"), params("repository"), baseUrl).get)
|
issues.html.issues(getRepository(params("owner"), params("repository"), baseUrl).get)
|
||||||
@@ -15,12 +26,16 @@ trait IssuesControllerBase extends ControllerBase { self: RepositoryService =>
|
|||||||
issues.html.issue(getRepository(params("owner"), params("repository"), baseUrl).get)
|
issues.html.issue(getRepository(params("owner"), params("repository"), baseUrl).get)
|
||||||
}
|
}
|
||||||
|
|
||||||
get("/:owner/:repository/issues/new"){
|
get("/:owner/:repository/issues/new")( usersOnly {
|
||||||
issues.html.issueedit(getRepository(params("owner"), params("repository"), baseUrl).get)
|
issues.html.issueedit(getRepository(params("owner"), params("repository"), baseUrl).get)
|
||||||
}
|
})
|
||||||
|
|
||||||
post("/:owner/:repository/issues"){
|
post("/:owner/:repository/issues", form)( usersOnly { form =>
|
||||||
redirect("%s/%s/issues".format(params("owner"), params("repository")))
|
val owner = params("owner")
|
||||||
}
|
val repository = params("repository")
|
||||||
|
|
||||||
|
redirect("/%s/%s/issues/%d".format(owner, repository,
|
||||||
|
saveIssue(owner, repository, context.loginAccount.get.userName, form.title, form.content)))
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,7 @@ object Issues extends Table[Issue]("ISSUE") {
|
|||||||
def content = column[String]("CONTENT")
|
def content = column[String]("CONTENT")
|
||||||
def registeredDate = column[java.sql.Date]("REGISTERED_DATE") // TODO convert java.util.Date later
|
def registeredDate = column[java.sql.Date]("REGISTERED_DATE") // TODO convert java.util.Date later
|
||||||
def updatedDate = column[java.sql.Date]("UPDATED_DATE")
|
def updatedDate = column[java.sql.Date]("UPDATED_DATE")
|
||||||
def * = userName ~ repositoryName ~ issueId ~ openedUserName ~ milestoneId.? ~ assignedUserName.? ~ title ~ content ~ registeredDate ~ updatedDate <> (Issue, Issue.unapply _)
|
def * = userName ~ repositoryName ~ issueId ~ openedUserName ~ milestoneId.? ~ assignedUserName.? ~ title ~ content.? ~ registeredDate ~ updatedDate <> (Issue, Issue.unapply _)
|
||||||
}
|
}
|
||||||
|
|
||||||
case class Issue(
|
case class Issue(
|
||||||
@@ -31,6 +31,6 @@ case class Issue(
|
|||||||
milestoneId: Option[Int],
|
milestoneId: Option[Int],
|
||||||
assignedUserName: Option[String],
|
assignedUserName: Option[String],
|
||||||
title: String,
|
title: String,
|
||||||
content: String,
|
content: Option[String],
|
||||||
registeredDate: java.sql.Date,
|
registeredDate: java.sql.Date,
|
||||||
updatedDate: java.sql.Date)
|
updatedDate: java.sql.Date)
|
||||||
@@ -9,10 +9,10 @@ import model._
|
|||||||
|
|
||||||
trait IssuesService {
|
trait IssuesService {
|
||||||
def saveIssue(owner: String, repository: String, loginUser: String,
|
def saveIssue(owner: String, repository: String, loginUser: String,
|
||||||
title: String, content: String) = {
|
title: String, content: Option[String]) =
|
||||||
// next id number
|
// next id number
|
||||||
val id = sql"SELECT ISSUE_ID + 1 FROM ISSUE_ID WHERE USER_NAME = $owner AND REPOSITORY_NAME = $repository FOR UPDATE".as[Int].first
|
sql"SELECT ISSUE_ID + 1 FROM ISSUE_ID WHERE USER_NAME = $owner AND REPOSITORY_NAME = $repository FOR UPDATE".as[Int]
|
||||||
|
.firstOption.filter { id =>
|
||||||
Issues insert Issue(
|
Issues insert Issue(
|
||||||
owner,
|
owner,
|
||||||
repository,
|
repository,
|
||||||
@@ -25,10 +25,10 @@ trait IssuesService {
|
|||||||
new java.sql.Date(System.currentTimeMillis), // TODO
|
new java.sql.Date(System.currentTimeMillis), // TODO
|
||||||
new java.sql.Date(System.currentTimeMillis))
|
new java.sql.Date(System.currentTimeMillis))
|
||||||
|
|
||||||
// increment id
|
// increment issue id
|
||||||
IssueId filter { t =>
|
IssueId.filter { t =>
|
||||||
(t.userName is owner.bind) && (t.repositoryName is repository.bind)
|
(t.userName is owner.bind) && (t.repositoryName is repository.bind)
|
||||||
} map (_.issueId) update(id)
|
}.map(_.issueId).update(id) > 0
|
||||||
}
|
} get
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -6,9 +6,10 @@
|
|||||||
|
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
<div class="span9">
|
<div class="span9">
|
||||||
<form action="@path/@repository.owner/@repository.name/issues" method="POST">
|
<form action="@path/@repository.owner/@repository.name/issues" method="POST" validate="true">
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="box-content">
|
<div class="box-content">
|
||||||
|
<span id="error-title" class="error"></span>
|
||||||
<input type="text" name="title" value="" placeholder="Title" style="width: 650px;"/>
|
<input type="text" name="title" value="" placeholder="Title" style="width: 650px;"/>
|
||||||
@*
|
@*
|
||||||
<ul class="nav nav-tabs">
|
<ul class="nav nav-tabs">
|
||||||
|
|||||||
Reference in New Issue
Block a user