Merge remote-tracking branch 'origin/master'

This commit is contained in:
takezoe
2013-06-26 15:59:30 +09:00
4 changed files with 80 additions and 6 deletions

View File

@@ -46,7 +46,7 @@ trait IssuesControllerBase extends ControllerBase {
getIssue(owner, repository, issueId) map {
issues.html.issue(
_,
getComment(owner, repository, issueId.toInt),
getComments(owner, repository, issueId.toInt),
getRepository(owner, repository, baseUrl).get)
} getOrElse NotFound
}
@@ -65,6 +65,16 @@ trait IssuesControllerBase extends ControllerBase {
saveIssue(owner, repository, context.loginAccount.get.userName, form.title, form.content)))
})
// TODO Authenticator
post("/:owner/:repository/issues/:id"){
// TODO update issue
contentType = formats("json")
org.json4s.jackson.Serialization.write(Map(
"title" -> "test title 2",
"content" -> view.Markdown.toHtml("* hoge", getRepository("root", "test", baseUrl).get, false, true, true)))
}
// TODO requires users only and readable repository checking
post("/:owner/:repository/issue_comments", commentForm)( usersOnly { form =>
val owner = params("owner")
@@ -74,6 +84,23 @@ trait IssuesControllerBase extends ControllerBase {
saveComment(owner, repository, context.loginAccount.get.userName, form.issueId, form.content)))
})
// TODO Authenticator
post("/:owner/:repository/issue_comments/:id"){
// TODO update issue memo
}
// TODO Authenticator
get("/:owner/:repository/issues/_data/:id"){
getIssue(params("owner"), params("repository"), params("id")) map { x =>
issues.html.edit(Some(x.title), x.content.getOrElse(""), x.issueId, x.userName, x.repositoryName)
} getOrElse NotFound
}
get("/:owner/:repository/issue_comments/_data/:id"){
getComment(params("id")) map { x =>
issues.html.edit(None, x.content, x.commentId, x.userName, x.repositoryName)
} getOrElse NotFound
}
private def searchIssues(filter: String) = {
val owner = params("owner")
val repository = params("repository")

View File

@@ -21,13 +21,18 @@ trait IssuesService {
} firstOption
else None
def getComment(owner: String, repository: String, issueId: Int) =
def getComments(owner: String, repository: String, issueId: Int) =
Query(IssueComments) filter { t =>
(t.userName is owner.bind) &&
(t.repositoryName is repository.bind) &&
(t.issueId is issueId.bind)
} list
def getComment(commentId: String) =
if (commentId forall (_.isDigit))
Query(IssueComments) filter (_.commentId is commentId.toInt.bind) firstOption
else None
/**
* Returns the count of the search result against issues.
*