feat: add IsPublic flag to team model

This commit is contained in:
Daniel Herrmann 2024-03-09 16:24:16 +01:00 committed by waza-ari
parent 8ea302899d
commit 9bc3e7cdb7
5 changed files with 71 additions and 1 deletions

View File

@ -0,0 +1,43 @@
// Vikunja is a to-do list application to facilitate your life.
// Copyright 2018-present Vikunja and contributors. All rights reserved.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public Licensee as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public Licensee for more details.
//
// You should have received a copy of the GNU Affero General Public Licensee
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package migration
import (
"src.techknowlogick.com/xormigrate"
"xorm.io/xorm"
)
type teams20240309111148 struct {
IsPublic bool `xorm:"not null default 0" json:"is_public"`
}
func (teams20240309111148) TableName() string {
return "teams"
}
func init() {
migrations = append(migrations, &xormigrate.Migration{
ID: "20240309111148",
Description: "Add IsPublic field to teams table to control discoverability of teams.",
Migrate: func(tx *xorm.Engine) error {
return tx.Sync2(teams20240309111148{})
},
Rollback: func(tx *xorm.Engine) error {
return nil
},
})
}

View File

@ -53,6 +53,9 @@ type Team struct {
// A timestamp when this relation was last updated. You cannot change this value.
Updated time.Time `xorm:"updated" json:"updated"`
// Defines wether the team should be publicly discoverable when sharing a project
IsPublic bool `xorm:"not null default 0" json:"is_public"`
web.CRUDable `xorm:"-" json:"-"`
web.Rights `xorm:"-" json:"-"`
}
@ -398,7 +401,7 @@ func (t *Team) Update(s *xorm.Session, _ web.Auth) (err error) {
return
}
_, err = s.ID(t.ID).Update(t)
_, err = s.ID(t.ID).UseBool("is_public").Update(t)
if err != nil {
return
}

View File

@ -8287,6 +8287,10 @@ const docTemplate = `{
"description": "The unique, numeric id of this team.",
"type": "integer"
},
"is_public": {
"description": "Defines wether the team should be publicly discoverable when sharing a project",
"type": "boolean"
},
"members": {
"description": "An array of all members in this team.",
"type": "array",
@ -8422,6 +8426,10 @@ const docTemplate = `{
"description": "The unique, numeric id of this team.",
"type": "integer"
},
"is_public": {
"description": "Defines wether the team should be publicly discoverable when sharing a project",
"type": "boolean"
},
"members": {
"description": "An array of all members in this team.",
"type": "array",

View File

@ -8279,6 +8279,10 @@
"description": "The unique, numeric id of this team.",
"type": "integer"
},
"is_public": {
"description": "Defines wether the team should be publicly discoverable when sharing a project",
"type": "boolean"
},
"members": {
"description": "An array of all members in this team.",
"type": "array",
@ -8414,6 +8418,10 @@
"description": "The unique, numeric id of this team.",
"type": "integer"
},
"is_public": {
"description": "Defines wether the team should be publicly discoverable when sharing a project",
"type": "boolean"
},
"members": {
"description": "An array of all members in this team.",
"type": "array",

View File

@ -894,6 +894,10 @@ definitions:
id:
description: The unique, numeric id of this team.
type: integer
is_public:
description: Defines wether the team should be publicly discoverable when
sharing a project
type: boolean
members:
description: An array of all members in this team.
items:
@ -1001,6 +1005,10 @@ definitions:
id:
description: The unique, numeric id of this team.
type: integer
is_public:
description: Defines wether the team should be publicly discoverable when
sharing a project
type: boolean
members:
description: An array of all members in this team.
items: