mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-07 05:55:51 +01:00
(refs #1286) Fix models
This commit is contained in:
@@ -7,7 +7,8 @@ trait CollaboratorComponent extends TemplateComponent { self: Profile =>
|
|||||||
|
|
||||||
class Collaborators(tag: Tag) extends Table[Collaborator](tag, "COLLABORATOR") with BasicTemplate {
|
class Collaborators(tag: Tag) extends Table[Collaborator](tag, "COLLABORATOR") with BasicTemplate {
|
||||||
val collaboratorName = column[String]("COLLABORATOR_NAME")
|
val collaboratorName = column[String]("COLLABORATOR_NAME")
|
||||||
def * = (userName, repositoryName, collaboratorName) <> (Collaborator.tupled, Collaborator.unapply)
|
val permission = column[String]("PERMISSION")
|
||||||
|
def * = (userName, repositoryName, collaboratorName, permission) <> (Collaborator.tupled, Collaborator.unapply)
|
||||||
|
|
||||||
def byPrimaryKey(owner: String, repository: String, collaborator: String) =
|
def byPrimaryKey(owner: String, repository: String, collaborator: String) =
|
||||||
byRepository(owner, repository) && (collaboratorName === collaborator.bind)
|
byRepository(owner, repository) && (collaboratorName === collaborator.bind)
|
||||||
@@ -17,5 +18,6 @@ trait CollaboratorComponent extends TemplateComponent { self: Profile =>
|
|||||||
case class Collaborator(
|
case class Collaborator(
|
||||||
userName: String,
|
userName: String,
|
||||||
repositoryName: String,
|
repositoryName: String,
|
||||||
collaboratorName: String
|
collaboratorName: String,
|
||||||
|
permission: String
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -23,11 +23,12 @@ trait RepositoryComponent extends TemplateComponent { self: Profile =>
|
|||||||
val allowWikiEditing = column[Boolean]("ALLOW_WIKI_EDITING")
|
val allowWikiEditing = column[Boolean]("ALLOW_WIKI_EDITING")
|
||||||
val externalWikiUrl = column[String]("EXTERNAL_WIKI_URL")
|
val externalWikiUrl = column[String]("EXTERNAL_WIKI_URL")
|
||||||
val allowFork = column[Boolean]("ALLOW_FORK")
|
val allowFork = column[Boolean]("ALLOW_FORK")
|
||||||
|
val allowCreateIssue = column[Boolean]("ALLOW_CREATE_ISSUE")
|
||||||
|
|
||||||
def * = (
|
def * = (
|
||||||
(userName, repositoryName, isPrivate, description.?, defaultBranch,
|
(userName, repositoryName, isPrivate, description.?, defaultBranch,
|
||||||
registeredDate, updatedDate, lastActivityDate, originUserName.?, originRepositoryName.?, parentUserName.?, parentRepositoryName.?),
|
registeredDate, updatedDate, lastActivityDate, originUserName.?, originRepositoryName.?, parentUserName.?, parentRepositoryName.?),
|
||||||
(enableIssues, externalIssuesUrl.?, enableWiki, allowWikiEditing, externalWikiUrl.?, allowFork)
|
(enableIssues, externalIssuesUrl.?, enableWiki, allowWikiEditing, externalWikiUrl.?, allowFork, allowCreateIssue)
|
||||||
).shaped <> (
|
).shaped <> (
|
||||||
{ case (repository, options) =>
|
{ case (repository, options) =>
|
||||||
Repository(
|
Repository(
|
||||||
@@ -90,5 +91,6 @@ case class RepositoryOptions(
|
|||||||
enableWiki: Boolean,
|
enableWiki: Boolean,
|
||||||
allowWikiEditing: Boolean,
|
allowWikiEditing: Boolean,
|
||||||
externalWikiUrl: Option[String],
|
externalWikiUrl: Option[String],
|
||||||
allowFork: Boolean
|
allowFork: Boolean,
|
||||||
|
allowCreateIssue: Boolean
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -43,7 +43,8 @@ trait RepositoryService { self: AccountService =>
|
|||||||
enableWiki = true,
|
enableWiki = true,
|
||||||
allowWikiEditing = true,
|
allowWikiEditing = true,
|
||||||
externalWikiUrl = None,
|
externalWikiUrl = None,
|
||||||
allowFork = true
|
allowFork = true,
|
||||||
|
allowCreateIssue = false
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -124,11 +125,8 @@ trait RepositoryService { self: AccountService =>
|
|||||||
repositoryName = newRepositoryName
|
repositoryName = newRepositoryName
|
||||||
)) :_*)
|
)) :_*)
|
||||||
|
|
||||||
if(account.isGroupAccount){
|
// TODO Drop transfered owner from collaborators?
|
||||||
Collaborators.insertAll(getGroupMembers(newUserName).map(m => Collaborator(newUserName, newRepositoryName, m.userName)) :_*)
|
|
||||||
} else {
|
|
||||||
Collaborators.insertAll(collaborators.map(_.copy(userName = newUserName, repositoryName = newRepositoryName)) :_*)
|
Collaborators.insertAll(collaborators.map(_.copy(userName = newUserName, repositoryName = newRepositoryName)) :_*)
|
||||||
}
|
|
||||||
|
|
||||||
// Update activity messages
|
// Update activity messages
|
||||||
Activities.filter { t =>
|
Activities.filter { t =>
|
||||||
@@ -340,7 +338,7 @@ trait RepositoryService { self: AccountService =>
|
|||||||
* Add collaborator (user or group) to the repository.
|
* Add collaborator (user or group) to the repository.
|
||||||
*/
|
*/
|
||||||
def addCollaborator(userName: String, repositoryName: String, collaboratorName: String)(implicit s: Session): Unit =
|
def addCollaborator(userName: String, repositoryName: String, collaboratorName: String)(implicit s: Session): Unit =
|
||||||
Collaborators insert Collaborator(userName, repositoryName, collaboratorName)
|
Collaborators insert Collaborator(userName, repositoryName, collaboratorName, "ADMIN") // TODO
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove collaborator (user or group) from the repository.
|
* Remove collaborator (user or group) from the repository.
|
||||||
@@ -358,7 +356,7 @@ trait RepositoryService { self: AccountService =>
|
|||||||
* Returns the list of collaborators name (user name or group name) which is sorted with ascending order.
|
* Returns the list of collaborators name (user name or group name) which is sorted with ascending order.
|
||||||
*/
|
*/
|
||||||
def getCollaborators(userName: String, repositoryName: String)(implicit s: Session): List[String] =
|
def getCollaborators(userName: String, repositoryName: String)(implicit s: Session): List[String] =
|
||||||
Collaborators.filter(_.byRepository(userName, repositoryName)).sortBy(_.collaboratorName).map(_.collaboratorName).list
|
Collaborators.filter(_.byRepository(userName, repositoryName)).sortBy(_.collaboratorName).map(_.collaboratorName).list // TODO return with permission
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of all collaborator name and permission which is sorted with ascending order.
|
* Returns the list of all collaborator name and permission which is sorted with ascending order.
|
||||||
|
|||||||
Reference in New Issue
Block a user