mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-02 03:26:06 +01:00
Rename general variable name isWritable to hasWritePermission.
This commit is contained in:
@@ -247,7 +247,7 @@ trait IssuesControllerBase extends ControllerBase {
|
||||
condition,
|
||||
filter,
|
||||
repositoryInfo,
|
||||
isWritable(owner, repository, context.loginAccount))
|
||||
hasWritePermission(owner, repository, context.loginAccount))
|
||||
|
||||
} getOrElse NotFound
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ trait MilestonesControllerBase extends ControllerBase {
|
||||
issues.milestones.html.list(state,
|
||||
getMilestonesWithIssueCount(owner, repository),
|
||||
repositoryInfo,
|
||||
isWritable(owner, repository, context.loginAccount))
|
||||
hasWritePermission(owner, repository, context.loginAccount))
|
||||
} getOrElse NotFound
|
||||
})
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ trait WikiControllerBase extends ControllerBase {
|
||||
|
||||
getRepository(owner, repository, baseUrl).map { repositoryInfo =>
|
||||
getWikiPage(owner, repository, "Home").map { page =>
|
||||
wiki.html.page("Home", page, repositoryInfo, isWritable(owner, repository, context.loginAccount))
|
||||
wiki.html.page("Home", page, repositoryInfo, hasWritePermission(owner, repository, context.loginAccount))
|
||||
} getOrElse redirect("/%s/%s/wiki/Home/_edit".format(owner, repository))
|
||||
} getOrElse NotFound
|
||||
})
|
||||
@@ -45,7 +45,7 @@ trait WikiControllerBase extends ControllerBase {
|
||||
|
||||
getRepository(owner, repository, baseUrl).map { repositoryInfo =>
|
||||
getWikiPage(owner, repository, pageName).map { page =>
|
||||
wiki.html.page(pageName, page, repositoryInfo, isWritable(owner, repository, context.loginAccount))
|
||||
wiki.html.page(pageName, page, repositoryInfo, hasWritePermission(owner, repository, context.loginAccount))
|
||||
} getOrElse redirect("/%s/%s/wiki/%s/_edit".format(owner, repository, pageName)) // TODO URLEncode
|
||||
} getOrElse NotFound
|
||||
})
|
||||
@@ -140,7 +140,7 @@ trait WikiControllerBase extends ControllerBase {
|
||||
val repository = params("repository")
|
||||
|
||||
getRepository(owner, repository, baseUrl).map {
|
||||
wiki.html.pages(getWikiPageList(owner, repository), _, isWritable(owner, repository, context.loginAccount))
|
||||
wiki.html.pages(getWikiPageList(owner, repository), _, hasWritePermission(owner, repository, context.loginAccount))
|
||||
} getOrElse NotFound
|
||||
})
|
||||
|
||||
|
||||
@@ -183,7 +183,7 @@ trait RepositoryService { self: AccountService =>
|
||||
def getCollaborators(userName: String, repositoryName: String): List[String] =
|
||||
Query(Collaborators).filter(_.byRepository(userName, repositoryName)).sortBy(_.collaboratorName).list.map(_.collaboratorName)
|
||||
|
||||
def isWritable(owner: String, repository: String, loginAccount: Option[Account]): Boolean = {
|
||||
def hasWritePermission(owner: String, repository: String, loginAccount: Option[Account]): Boolean = {
|
||||
loginAccount match {
|
||||
case Some(a) if(a.isAdmin) => true
|
||||
case Some(a) if(a.userName == owner) => true
|
||||
|
||||
@@ -56,6 +56,7 @@ class BasicAuthenticationFilter extends Filter with RepositoryService with Accou
|
||||
private def isWritableUser(username: String, password: String, repository: RepositoryService.RepositoryInfo): Boolean = {
|
||||
getAccountByUserName(username) match {
|
||||
case Some(account) if(account.password == encrypt(password)) => {
|
||||
// TODO Use hasWritePermission?
|
||||
(account.isAdmin // administrator
|
||||
|| account.userName == repository.owner // repository owner
|
||||
|| getCollaborators(repository.owner, repository.name).contains(account.userName)) // collaborator
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
condition: service.IssuesService.IssueSearchCondition,
|
||||
filter: String,
|
||||
repository: service.RepositoryService.RepositoryInfo,
|
||||
isWritable: Boolean)(implicit context: app.Context)
|
||||
hasWritePermission: Boolean)(implicit context: app.Context)
|
||||
@import context._
|
||||
@import view.helpers._
|
||||
@html.main("Issues - " + repository.owner + "/" + repository.name){
|
||||
@@ -86,7 +86,7 @@
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@if(isWritable){
|
||||
@if(hasWritePermission){
|
||||
<hr/>
|
||||
<input type="button" class="btn btn-block" id="manageLabel" data-toggle="button" value="Manage Labels"/>
|
||||
<br/>
|
||||
@@ -169,7 +169,7 @@
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@if(isWritable){
|
||||
@if(hasWritePermission){
|
||||
<script>
|
||||
$(function(){
|
||||
$('#manageLabel').click(function(){
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
@(state: String, milestones: List[(model.Milestone, Int, Int)], repository: service.RepositoryService.RepositoryInfo, isWritable: Boolean)(implicit context: app.Context)
|
||||
@(state: String,
|
||||
milestones: List[(model.Milestone, Int, Int)],
|
||||
repository: service.RepositoryService.RepositoryInfo,
|
||||
hasWritePermission: Boolean)(implicit context: app.Context)
|
||||
@import context._
|
||||
@import view.helpers._
|
||||
@html.main("Milestones - " + repository.owner + "/" + repository.name){
|
||||
@@ -20,7 +23,7 @@
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
@if(isWritable){
|
||||
@if(hasWritePermission){
|
||||
<hr>
|
||||
<a href="@url(repository)/issues/milestones/new" class="btn btn-block">Create a new milestone</a>
|
||||
}
|
||||
@@ -49,7 +52,7 @@
|
||||
<div class="span8">
|
||||
<div class="milestone-menu">
|
||||
<div class="pull-right">
|
||||
@if(isWritable){
|
||||
@if(hasWritePermission){
|
||||
<a href="@url(repository)/issues/milestones/@milestone.milestoneId/edit">Edit
|
||||
@if(milestone.closedDate.isDefined){
|
||||
<a href="@url(repository)/issues/milestones/@milestone.milestoneId/open">Open</a>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
@(pageName: String,
|
||||
page: service.WikiService.WikiPageInfo,
|
||||
repository: service.RepositoryService.RepositoryInfo,
|
||||
isWritable: Boolean)(implicit context: app.Context)
|
||||
hasWritePermission: Boolean)(implicit context: app.Context)
|
||||
@import context._
|
||||
@import view.helpers._
|
||||
@html.main(pageName + " - " + repository.owner + "/" + repository.name){
|
||||
@@ -13,7 +13,7 @@
|
||||
</li>
|
||||
<li class="pull-right">
|
||||
<div class="btn-group">
|
||||
@if(isWritable){
|
||||
@if(hasWritePermission){
|
||||
<a class="btn" href="@url(repository)/wiki/_new">New Page</a>
|
||||
<a class="btn" href="@url(repository)/wiki/@pageName/_edit">Edit Page</a>
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@(pages: List[String], repository: service.RepositoryService.RepositoryInfo, isWritable: Boolean)(implicit context: app.Context)
|
||||
@(pages: List[String], repository: service.RepositoryService.RepositoryInfo, hasWritePermission: Boolean)(implicit context: app.Context)
|
||||
@import context._
|
||||
@import view.helpers._
|
||||
@html.main("Pages - " + repository.owner + "/" + repository.name){
|
||||
@@ -10,7 +10,7 @@
|
||||
</li>
|
||||
<li class="pull-right">
|
||||
<div class="btn-group">
|
||||
@if(isWritable){
|
||||
@if(hasWritePermission){
|
||||
<a class="btn" href="@url(repository)/wiki/_new">New Page</a>
|
||||
}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user