diff options
author | Unknown <joe2010xtmf@163.com> | 2014-06-25 05:14:36 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-06-25 05:14:36 -0400 |
commit | 43b33440b53c79a22de08880851b5b55e9b6a4b3 (patch) | |
tree | 4ae44f5d94aa99149035c04e518a91090fe4932a /models/org.go | |
parent | 72ba273cc99589d7a0ca0a7986939e86f6599bf8 (diff) | |
download | gitea-43b33440b53c79a22de08880851b5b55e9b6a4b3.tar.gz gitea-43b33440b53c79a22de08880851b5b55e9b6a4b3.zip |
Work on create organization repo and #257
Diffstat (limited to 'models/org.go')
-rw-r--r-- | models/org.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/models/org.go b/models/org.go index 1cfe179846..227151ab02 100644 --- a/models/org.go +++ b/models/org.go @@ -12,6 +12,8 @@ const ( ORG_ADMIN ) +const OWNER_TEAM = "Owner" + // Team represents a organization team. type Team struct { Id int64 @@ -19,6 +21,7 @@ type Team struct { Name string Description string Authorize AuthorizeType + RepoIds string `xorm:"TEXT"` NumMembers int NumRepos int } @@ -29,6 +32,15 @@ func NewTeam(t *Team) error { return err } +func UpdateTeam(t *Team) error { + if len(t.Description) > 255 { + t.Description = t.Description[:255] + } + + _, err := x.Id(t.Id).AllCols().Update(t) + return err +} + // ________ ____ ___ // \_____ \_______ ____ | | \______ ___________ // / | \_ __ \/ ___\| | / ___// __ \_ __ \ @@ -53,6 +65,13 @@ func GetOrgUsersByUserId(uid int64) ([]*OrgUser, error) { return ous, err } +// GetOrgUsersByOrgId returns all organization-user relations by organization ID. +func GetOrgUsersByOrgId(orgId int64) ([]*OrgUser, error) { + ous := make([]*OrgUser, 0, 10) + err := x.Where("org_id=?", orgId).Find(&ous) + return ous, err +} + // ___________ ____ ___ // \__ ___/___ _____ _____ | | \______ ___________ // | |_/ __ \\__ \ / \| | / ___// __ \_ __ \ @@ -67,3 +86,21 @@ type TeamUser struct { OrgId int64 `xorm:"INDEX"` TeamId int64 } + +// GetTeamMembers returns all members in given team of organization. +func GetTeamMembers(orgId, teamId int64) ([]*User, error) { + tus := make([]*TeamUser, 0, 10) + err := x.Where("org_id=?", orgId).And("team_id=?", teamId).Find(&tus) + if err != nil { + return nil, err + } + + us := make([]*User, len(tus)) + for i, tu := range tus { + us[i], err = GetUserById(tu.Uid) + if err != nil { + return nil, err + } + } + return us, nil +} |