fixed lint
This commit is contained in:
parent
7dc4cd2173
commit
b11bd9f0b1
3 changed files with 5 additions and 2 deletions
|
@ -54,6 +54,7 @@ func (TeamMember) TableName() string {
|
||||||
return "team_members"
|
return "team_members"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TeamUser is the team member type
|
||||||
type TeamUser struct {
|
type TeamUser struct {
|
||||||
User `xorm:"extends"`
|
User `xorm:"extends"`
|
||||||
IsAdmin bool `json:"is_admin"`
|
IsAdmin bool `json:"is_admin"`
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package models
|
package models
|
||||||
|
|
||||||
|
// Delete deletes a team
|
||||||
func (t *Team) Delete(id int64) (err error) {
|
func (t *Team) Delete(id int64) (err error) {
|
||||||
|
|
||||||
// Check if the team exists
|
// Check if the team exists
|
||||||
|
|
|
@ -18,13 +18,13 @@ func (t *Team) CanUpdate(user *User, id int64) bool {
|
||||||
return exists
|
return exists
|
||||||
}
|
}
|
||||||
|
|
||||||
// CanDelete
|
// CanDelete checks if a user can delete a team
|
||||||
func (t *Team) CanDelete(user *User, id int64) bool {
|
func (t *Team) CanDelete(user *User, id int64) bool {
|
||||||
t.ID = id
|
t.ID = id
|
||||||
return t.IsAdmin(user)
|
return t.IsAdmin(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsAdmin
|
// IsAdmin returns true when the user is admin of a team
|
||||||
func (t *Team) IsAdmin(user *User) bool {
|
func (t *Team) IsAdmin(user *User) bool {
|
||||||
exists, _ := x.Where("team_id = ?", t.ID).
|
exists, _ := x.Where("team_id = ?", t.ID).
|
||||||
And("user_id = ?", user.ID).
|
And("user_id = ?", user.ID).
|
||||||
|
@ -33,6 +33,7 @@ func (t *Team) IsAdmin(user *User) bool {
|
||||||
return exists
|
return exists
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CanRead returns true if the user has read access to the team
|
||||||
func (t *Team) CanRead(user *User) bool {
|
func (t *Team) CanRead(user *User) bool {
|
||||||
// Check if the user is in the team
|
// Check if the user is in the team
|
||||||
exists, _ := x.Where("team_id = ?", t.ID).
|
exists, _ := x.Where("team_id = ?", t.ID).
|
||||||
|
|
Loading…
Add table
Reference in a new issue