summaryrefslogtreecommitdiffstats
path: root/models/repo_collaboration.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/repo_collaboration.go')
-rw-r--r--models/repo_collaboration.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/models/repo_collaboration.go b/models/repo_collaboration.go
index 1199a56404..08d2062dbb 100644
--- a/models/repo_collaboration.go
+++ b/models/repo_collaboration.go
@@ -51,7 +51,7 @@ func (repo *Repository) addCollaborator(e db.Engine, u *User) error {
// AddCollaborator adds new collaboration to a repository with default access mode.
func (repo *Repository) AddCollaborator(u *User) error {
- sess := db.DefaultContext().NewSession()
+ sess := db.NewSession(db.DefaultContext)
defer sess.Close()
if err := sess.Begin(); err != nil {
return err
@@ -104,12 +104,12 @@ func (repo *Repository) getCollaborators(e db.Engine, listOptions ListOptions) (
// GetCollaborators returns the collaborators for a repository
func (repo *Repository) GetCollaborators(listOptions ListOptions) ([]*Collaborator, error) {
- return repo.getCollaborators(db.DefaultContext().Engine(), listOptions)
+ return repo.getCollaborators(db.GetEngine(db.DefaultContext), listOptions)
}
// CountCollaborators returns total number of collaborators for a repository
func (repo *Repository) CountCollaborators() (int64, error) {
- return db.DefaultContext().Engine().Where("repo_id = ? ", repo.ID).Count(&Collaboration{})
+ return db.GetEngine(db.DefaultContext).Where("repo_id = ? ", repo.ID).Count(&Collaboration{})
}
func (repo *Repository) getCollaboration(e db.Engine, uid int64) (*Collaboration, error) {
@@ -130,7 +130,7 @@ func (repo *Repository) isCollaborator(e db.Engine, userID int64) (bool, error)
// IsCollaborator check if a user is a collaborator of a repository
func (repo *Repository) IsCollaborator(userID int64) (bool, error) {
- return repo.isCollaborator(db.DefaultContext().Engine(), userID)
+ return repo.isCollaborator(db.GetEngine(db.DefaultContext), userID)
}
func (repo *Repository) changeCollaborationAccessMode(e db.Engine, uid int64, mode AccessMode) error {
@@ -169,7 +169,7 @@ func (repo *Repository) changeCollaborationAccessMode(e db.Engine, uid int64, mo
// ChangeCollaborationAccessMode sets new access mode for the collaboration.
func (repo *Repository) ChangeCollaborationAccessMode(uid int64, mode AccessMode) error {
- sess := db.DefaultContext().NewSession()
+ sess := db.NewSession(db.DefaultContext)
defer sess.Close()
if err := sess.Begin(); err != nil {
return err
@@ -189,7 +189,7 @@ func (repo *Repository) DeleteCollaboration(uid int64) (err error) {
UserID: uid,
}
- sess := db.DefaultContext().NewSession()
+ sess := db.NewSession(db.DefaultContext)
defer sess.Close()
if err = sess.Begin(); err != nil {
return err
@@ -259,7 +259,7 @@ func (repo *Repository) getRepoTeams(e db.Engine) (teams []*Team, err error) {
// GetRepoTeams gets the list of teams that has access to the repository
func (repo *Repository) GetRepoTeams() ([]*Team, error) {
- return repo.getRepoTeams(db.DefaultContext().Engine())
+ return repo.getRepoTeams(db.GetEngine(db.DefaultContext))
}
// IsOwnerMemberCollaborator checks if a provided user is the owner, a collaborator or a member of a team in a repository
@@ -267,7 +267,7 @@ func (repo *Repository) IsOwnerMemberCollaborator(userID int64) (bool, error) {
if repo.OwnerID == userID {
return true, nil
}
- teamMember, err := db.DefaultContext().Engine().Join("INNER", "team_repo", "team_repo.team_id = team_user.team_id").
+ teamMember, err := db.GetEngine(db.DefaultContext).Join("INNER", "team_repo", "team_repo.team_id = team_user.team_id").
Join("INNER", "team_unit", "team_unit.team_id = team_user.team_id").
Where("team_repo.repo_id = ?", repo.ID).
And("team_unit.`type` = ?", UnitTypeCode).
@@ -279,5 +279,5 @@ func (repo *Repository) IsOwnerMemberCollaborator(userID int64) (bool, error) {
return true, nil
}
- return db.DefaultContext().Engine().Get(&Collaboration{RepoID: repo.ID, UserID: userID})
+ return db.GetEngine(db.DefaultContext).Get(&Collaboration{RepoID: repo.ID, UserID: userID})
}