mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-06 21:45:50 +01:00
(refs #4)Add issue close, reopen and comment activity.
This commit is contained in:
@@ -4,6 +4,7 @@ CREATE TABLE ACTIVITY(
|
|||||||
REPOSITORY_NAME VARCHAR(100) NOT NULL,
|
REPOSITORY_NAME VARCHAR(100) NOT NULL,
|
||||||
ACTIVITY_USER_NAME VARCHAR(100) NOT NULL,
|
ACTIVITY_USER_NAME VARCHAR(100) NOT NULL,
|
||||||
MESSAGE TEXT NOT NULL,
|
MESSAGE TEXT NOT NULL,
|
||||||
|
ADDITIONAL_INFO TEXT,
|
||||||
ACTIVITY_DATE TIMESTAMP NOT NULL
|
ACTIVITY_DATE TIMESTAMP NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ trait CreateRepositoryControllerBase extends ControllerBase {
|
|||||||
createWikiRepository(loginAccount, form.name)
|
createWikiRepository(loginAccount, form.name)
|
||||||
|
|
||||||
// Record activity
|
// Record activity
|
||||||
recordCreateRepository(loginUserName, form.name, loginUserName)
|
recordCreateRepositoryActivity(loginUserName, form.name, loginUserName)
|
||||||
|
|
||||||
// redirect to the repository
|
// redirect to the repository
|
||||||
redirect("/%s/%s".format(loginUserName, form.name))
|
redirect("/%s/%s".format(loginUserName, form.name))
|
||||||
|
|||||||
@@ -88,10 +88,12 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
val writable = hasWritePermission(owner, name, context.loginAccount)
|
val writable = hasWritePermission(owner, name, context.loginAccount)
|
||||||
val userName = context.loginAccount.get.userName
|
val userName = context.loginAccount.get.userName
|
||||||
|
|
||||||
|
// insert issue
|
||||||
val issueId = createIssue(owner, name, userName, form.title, form.content,
|
val issueId = createIssue(owner, name, userName, form.title, form.content,
|
||||||
if(writable) form.assignedUserName else None,
|
if(writable) form.assignedUserName else None,
|
||||||
if(writable) form.milestoneId else None)
|
if(writable) form.milestoneId else None)
|
||||||
|
|
||||||
|
// insert labels
|
||||||
if(writable){
|
if(writable){
|
||||||
form.labelNames.map { value =>
|
form.labelNames.map { value =>
|
||||||
val labels = getLabels(owner, name)
|
val labels = getLabels(owner, name)
|
||||||
@@ -103,7 +105,8 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
recordCreateIssue(owner, name, userName, issueId)
|
// record activity
|
||||||
|
recordCreateIssueActivity(owner, name, userName, issueId, form.title)
|
||||||
|
|
||||||
redirect("/%s/%s/issues/%d".format(owner, name, issueId))
|
redirect("/%s/%s/issues/%d".format(owner, name, issueId))
|
||||||
})
|
})
|
||||||
@@ -123,19 +126,26 @@ trait IssuesControllerBase extends ControllerBase {
|
|||||||
post("/:owner/:repository/issue_comments/new", commentForm)(readableUsersOnly { (form, repository) =>
|
post("/:owner/:repository/issue_comments/new", commentForm)(readableUsersOnly { (form, repository) =>
|
||||||
val owner = repository.owner
|
val owner = repository.owner
|
||||||
val name = repository.name
|
val name = repository.name
|
||||||
|
val userName = context.loginAccount.get.userName
|
||||||
|
|
||||||
getIssue(owner, name, form.issueId.toString).map { issue =>
|
getIssue(owner, name, form.issueId.toString).map { issue =>
|
||||||
redirect("/%s/%s/issues/%d#comment-%d".format(
|
val action = if(isEditable(owner, name, issue.openedUserName)){
|
||||||
owner, name, form.issueId,
|
|
||||||
createComment(owner, name, context.loginAccount.get.userName,
|
|
||||||
form.issueId,
|
|
||||||
form.content,
|
|
||||||
if(isEditable(owner, name, issue.openedUserName)){
|
|
||||||
params.get("action") filter { action =>
|
params.get("action") filter { action =>
|
||||||
updateClosed(owner, name, form.issueId, if(action == "close") true else false) > 0
|
updateClosed(owner, name, form.issueId, if(action == "close") true else false) > 0
|
||||||
}
|
}
|
||||||
} else None)
|
} else None
|
||||||
))
|
|
||||||
|
val commentId = createComment(owner, name, userName, form.issueId, form.content, action)
|
||||||
|
|
||||||
|
// record activity
|
||||||
|
recordCommentIssueActivity(owner, name, userName, issue.issueId, form.content)
|
||||||
|
action match {
|
||||||
|
case Some("reopen") => recordReopenIssueActivity(owner, name, userName, issue.issueId, issue.title)
|
||||||
|
case Some("close") => recordCloseIssueActivity(owner, name, userName, issue.issueId, issue.title)
|
||||||
|
case _ =>
|
||||||
|
}
|
||||||
|
|
||||||
|
redirect("/%s/%s/issues/%d#comment-%d".format(owner, name, form.issueId, commentId))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,10 @@ object Activities extends Table[Activity]("ACTIVITY") with BasicTemplate with Fu
|
|||||||
def activityId = column[Int]("ACTIVITY_ID", O AutoInc)
|
def activityId = column[Int]("ACTIVITY_ID", O AutoInc)
|
||||||
def activityUserName = column[String]("ACTIVITY_USER_NAME")
|
def activityUserName = column[String]("ACTIVITY_USER_NAME")
|
||||||
def message = column[String]("MESSAGE")
|
def message = column[String]("MESSAGE")
|
||||||
|
def additionalInfo = column[String]("ADDITIONAL_INFO")
|
||||||
def activityDate = column[java.util.Date]("ACTIVITY_DATE")
|
def activityDate = column[java.util.Date]("ACTIVITY_DATE")
|
||||||
def * = activityId ~ userName ~ repositoryName ~ activityUserName ~ message ~ activityDate <> (Activity, Activity.unapply _)
|
def * = activityId ~ userName ~ repositoryName ~ activityUserName ~ message ~ additionalInfo.? ~ activityDate <> (Activity, Activity.unapply _)
|
||||||
def autoInc = userName ~ repositoryName ~ activityUserName ~ message ~ activityDate returning activityId
|
def autoInc = userName ~ repositoryName ~ activityUserName ~ message ~ additionalInfo.? ~ activityDate returning activityId
|
||||||
}
|
}
|
||||||
|
|
||||||
case class Activity(
|
case class Activity(
|
||||||
@@ -17,5 +18,6 @@ case class Activity(
|
|||||||
repositoryName: String,
|
repositoryName: String,
|
||||||
activityUserName: String,
|
activityUserName: String,
|
||||||
message: String,
|
message: String,
|
||||||
|
additionalInfo: Option[String],
|
||||||
activityDate: java.util.Date
|
activityDate: java.util.Date
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -21,13 +21,28 @@ trait ActivityService {
|
|||||||
.list
|
.list
|
||||||
}
|
}
|
||||||
|
|
||||||
def recordCreateRepository(userName: String, repositoryName: String, activityUserName: String): Unit =
|
def recordCreateRepositoryActivity(userName: String, repositoryName: String, activityUserName: String): Unit =
|
||||||
Activities.autoInc insert(userName, repositoryName, activityUserName,
|
Activities.autoInc insert(userName, repositoryName, activityUserName,
|
||||||
"[[%s]] created [[%s/%s]]".format(activityUserName, userName, repositoryName),
|
"[[%s]] created [[%s/%s]]".format(activityUserName, userName, repositoryName),
|
||||||
currentDate)
|
None, currentDate)
|
||||||
|
|
||||||
def recordCreateIssue(userName: String, repositoryName: String, activityUserName: String, issueId: Int): Unit =
|
def recordCreateIssueActivity(userName: String, repositoryName: String, activityUserName: String, issueId: Int, title: String): Unit =
|
||||||
Activities.autoInc insert(userName, repositoryName, activityUserName,
|
Activities.autoInc insert(userName, repositoryName, activityUserName,
|
||||||
"[[%s]] opened issue [[%s/%s#%d]]".format(activityUserName, userName, repositoryName, issueId),
|
"[[%s]] opened issue [[%s/%s#%d]]".format(activityUserName, userName, repositoryName, issueId),
|
||||||
currentDate)
|
Some(title), currentDate)
|
||||||
|
|
||||||
|
def recordCloseIssueActivity(userName: String, repositoryName: String, activityUserName: String, issueId: Int, title: String): Unit =
|
||||||
|
Activities.autoInc insert(userName, repositoryName, activityUserName,
|
||||||
|
"[[%s]] closed issue [[%s/%s#%d]]".format(activityUserName, userName, repositoryName, issueId),
|
||||||
|
Some(title), currentDate)
|
||||||
|
|
||||||
|
def recordReopenIssueActivity(userName: String, repositoryName: String, activityUserName: String, issueId: Int, title: String): Unit =
|
||||||
|
Activities.autoInc insert(userName, repositoryName, activityUserName,
|
||||||
|
"[[%s]] closed reopened [[%s/%s#%d]]".format(activityUserName, userName, repositoryName, issueId),
|
||||||
|
Some(title), currentDate)
|
||||||
|
|
||||||
|
def recordCommentIssueActivity(userName: String, repositoryName: String, activityUserName: String, issueId: Int, comment: String): Unit =
|
||||||
|
Activities.autoInc insert(userName, repositoryName, activityUserName,
|
||||||
|
"[[%s]] commented on issue [[%s/%s#%d]]".format(activityUserName, userName, repositoryName, issueId),
|
||||||
|
Some(comment), currentDate)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,11 @@
|
|||||||
} else {
|
} else {
|
||||||
@activities.map { activity =>
|
@activities.map { activity =>
|
||||||
<div class="block">
|
<div class="block">
|
||||||
<div class="muted small">@datetime(activity.activityDate)</div>
|
<div class="muted smal">@datetime(activity.activityDate)</div>
|
||||||
<div>@activityMessage(activity.message)</div>
|
<div class="strong">@activityMessage(activity.message)</div>
|
||||||
|
@activity.additionalInfo.map { additionalInfo =>
|
||||||
|
<div>@additionalInfo</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user