Browse Source

Add field IsAllRepositories to team

pull/6791/head
Nicolas Gourdon 5 years ago
parent
commit
0b8e90e39b
4 changed files with 45 additions and 16 deletions
  1. 2
    0
      models/migrations/migrations.go
  2. 25
    0
      models/migrations/v85.go
  3. 6
    5
      models/org.go
  4. 12
    11
      models/org_team.go

+ 2
- 0
models/migrations/migrations.go View File

@@ -223,6 +223,8 @@ var migrations = []Migration{
NewMigration("add uploader id for table attachment", addUploaderIDForAttachment),
// v84 -> v85
NewMigration("add table to store original imported gpg keys", addGPGKeyImport),
// v85 -> v86
NewMigration("add is_all_repositories to teams", addTeamIsAllRepositories),
}

// Migrate database to current version

+ 25
- 0
models/migrations/v85.go View File

@@ -0,0 +1,25 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

package migrations

import (
"github.com/go-xorm/xorm"
)

func addTeamIsAllRepositories(x *xorm.Engine) error {

type Team struct {
ID int64 `xorm:"pk autoincr"`
IsAllRepositories bool `xorm:"NOT NULL DEFAULT false"`
}

if err := x.Sync2(new(Team)); err != nil {
return err
}

_, err := x.Exec("UPDATE team SET is_all_repositories = ? WHERE name=?",
true, "Owners")
return err
}

+ 6
- 5
models/org.go View File

@@ -151,11 +151,12 @@ func CreateOrganization(org, owner *User) (err error) {

// Create default owner team.
t := &Team{
OrgID: org.ID,
LowerName: strings.ToLower(ownerTeamName),
Name: ownerTeamName,
Authorize: AccessModeOwner,
NumMembers: 1,
OrgID: org.ID,
LowerName: strings.ToLower(ownerTeamName),
Name: ownerTeamName,
Authorize: AccessModeOwner,
NumMembers: 1,
IsAllRepositories: true,
}
if _, err = sess.Insert(t); err != nil {
return fmt.Errorf("insert owner team: %v", err)

+ 12
- 11
models/org_team.go View File

@@ -21,17 +21,18 @@ const ownerTeamName = "Owners"

// Team represents a organization team.
type Team struct {
ID int64 `xorm:"pk autoincr"`
OrgID int64 `xorm:"INDEX"`
LowerName string
Name string
Description string
Authorize AccessMode
Repos []*Repository `xorm:"-"`
Members []*User `xorm:"-"`
NumRepos int
NumMembers int
Units []*TeamUnit `xorm:"-"`
ID int64 `xorm:"pk autoincr"`
OrgID int64 `xorm:"INDEX"`
LowerName string
Name string
Description string
Authorize AccessMode
Repos []*Repository `xorm:"-"`
Members []*User `xorm:"-"`
NumRepos int
NumMembers int
Units []*TeamUnit `xorm:"-"`
IsAllRepositories bool `xorm:"NOT NULL DEFAULT false"`
}

// ColorFormat provides a basic color format for a Team

Loading…
Cancel
Save