summaryrefslogtreecommitdiffstats
path: root/models/repo.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-08-10 21:47:23 +0800
committerUnknwon <u@gogs.io>2015-08-10 21:47:23 +0800
commit75aff60c903c2c5ab92d75c9f067d6815f3daa2e (patch)
treee12104d0fbb25f15c41ee83c6c47acf9841df703 /models/repo.go
parent09a1b2a1f5ca4c510be2828635a790b2a775ac94 (diff)
downloadgitea-75aff60c903c2c5ab92d75c9f067d6815f3daa2e.tar.gz
gitea-75aff60c903c2c5ab92d75c9f067d6815f3daa2e.zip
finish create issue with milestone and assignee
Diffstat (limited to 'models/repo.go')
-rw-r--r--models/repo.go39
1 files changed, 38 insertions, 1 deletions
diff --git a/models/repo.go b/models/repo.go
index 7355b5e8d2..1c4f09c4d7 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -177,6 +177,43 @@ func (repo *Repository) GetOwner() (err error) {
return repo.getOwner(x)
}
+// GetAssignees returns all users that have write access of repository.
+func (repo *Repository) GetAssignees() (_ []*User, err error) {
+ if err = repo.GetOwner(); err != nil {
+ return nil, err
+ }
+
+ accesses := make([]*Access, 0, 10)
+ if err = x.Where("repo_id=? AND mode>=?", repo.ID, ACCESS_MODE_WRITE).Find(&accesses); err != nil {
+ return nil, err
+ }
+
+ users := make([]*User, 0, len(accesses)+1) // Just waste 1 unit does not matter.
+ if !repo.Owner.IsOrganization() {
+ users = append(users, repo.Owner)
+ }
+
+ var u *User
+ for i := range accesses {
+ u, err = GetUserByID(accesses[i].UserID)
+ if err != nil {
+ return nil, err
+ }
+ users = append(users, u)
+ }
+ return users, nil
+}
+
+// GetAssigneeByID returns the user that has write access of repository by given ID.
+func (repo *Repository) GetAssigneeByID(userID int64) (*User, error) {
+ return GetAssigneeByID(repo, userID)
+}
+
+// GetMilestoneByID returns the milestone belongs to repository by given ID.
+func (repo *Repository) GetMilestoneByID(milestoneID int64) (*Milestone, error) {
+ return GetRepoMilestoneByID(repo.ID, milestoneID)
+}
+
func (repo *Repository) GetMirror() (err error) {
repo.Mirror, err = GetMirror(repo.ID)
return err
@@ -876,7 +913,7 @@ func DeleteRepository(uid, repoID int64, userName string) error {
return err
} else if _, err = sess.Delete(&Mirror{RepoID: repoID}); err != nil {
return err
- } else if _, err = sess.Delete(&IssueUser{RepoId: repoID}); err != nil {
+ } else if _, err = sess.Delete(&IssueUser{RepoID: repoID}); err != nil {
return err
} else if _, err = sess.Delete(&Milestone{RepoID: repoID}); err != nil {
return err