mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-06 21:45:50 +01:00
(refs #4)Record issue creation activity.
This commit is contained in:
@@ -8,11 +8,11 @@ import util.{CollaboratorsAuthenticator, ReferrerAuthenticator, ReadableUsersAut
|
||||
import org.scalatra.Ok
|
||||
|
||||
class IssuesController extends IssuesControllerBase
|
||||
with IssuesService with RepositoryService with AccountService with LabelsService with MilestonesService
|
||||
with IssuesService with RepositoryService with AccountService with LabelsService with MilestonesService with ActivityService
|
||||
with ReadableUsersAuthenticator with ReferrerAuthenticator with CollaboratorsAuthenticator
|
||||
|
||||
trait IssuesControllerBase extends ControllerBase {
|
||||
self: IssuesService with RepositoryService with LabelsService with MilestonesService
|
||||
self: IssuesService with RepositoryService with LabelsService with MilestonesService with ActivityService
|
||||
with ReadableUsersAuthenticator with ReferrerAuthenticator with CollaboratorsAuthenticator =>
|
||||
|
||||
case class IssueCreateForm(title: String, content: Option[String],
|
||||
@@ -86,8 +86,9 @@ trait IssuesControllerBase extends ControllerBase {
|
||||
val owner = repository.owner
|
||||
val name = repository.name
|
||||
val writable = hasWritePermission(owner, name, context.loginAccount)
|
||||
val userName = context.loginAccount.get.userName
|
||||
|
||||
val issueId = createIssue(owner, name, context.loginAccount.get.userName, form.title, form.content,
|
||||
val issueId = createIssue(owner, name, userName, form.title, form.content,
|
||||
if(writable) form.assignedUserName else None,
|
||||
if(writable) form.milestoneId else None)
|
||||
|
||||
@@ -102,6 +103,8 @@ trait IssuesControllerBase extends ControllerBase {
|
||||
}
|
||||
}
|
||||
|
||||
recordCreateIssue(owner, name, userName, issueId)
|
||||
|
||||
redirect("/%s/%s/issues/%d".format(owner, name, issueId))
|
||||
})
|
||||
|
||||
|
||||
@@ -21,10 +21,13 @@ trait ActivityService {
|
||||
.list
|
||||
}
|
||||
|
||||
def recordCreateRepository(userName: String, repositoryName: String, activityUserName: String): Unit = {
|
||||
def recordCreateRepository(userName: String, repositoryName: String, activityUserName: String): Unit =
|
||||
Activities.autoInc insert(userName, repositoryName, activityUserName,
|
||||
"[[%s]] created [[%s/%s]]".format(activityUserName, userName, repositoryName),
|
||||
currentDate)
|
||||
}
|
||||
|
||||
def recordCreateIssue(userName: String, repositoryName: String, activityUserName: String, issueId: Int): Unit =
|
||||
Activities.autoInc insert(userName, repositoryName, activityUserName,
|
||||
"[[%s]] opened issue [[%s/%s#%d]]".format(activityUserName, userName, repositoryName, issueId),
|
||||
currentDate)
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ object helpers {
|
||||
|
||||
def activityMessage(message: String)(implicit context: app.Context): Html = {
|
||||
Html(message
|
||||
.replaceAll("\\[\\[([^\\s]+?)/([^\\s]+?)#((\\d+))\\]\\]", "<a href=\"%s/$1/$2/issues/$3\">$1/$2#$3</a>".format(context.path))
|
||||
.replaceAll("\\[\\[([^\\s]+?)/([^\\s]+?)\\]\\]", "<a href=\"%s/$1/$2\">$1/$2</a>".format(context.path))
|
||||
.replaceAll("\\[\\[([^\\s]+?)\\]\\]", "<a href=\"%s/$1\">$1</a>".format(context.path))
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user