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"
|
||||
}
|
||||
|
||||
// TeamUser is the team member type
|
||||
type TeamUser struct {
|
||||
User `xorm:"extends"`
|
||||
IsAdmin bool `json:"is_admin"`
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package models
|
||||
|
||||
// Delete deletes a team
|
||||
func (t *Team) Delete(id int64) (err error) {
|
||||
|
||||
// Check if the team exists
|
||||
|
|
|
@ -18,13 +18,13 @@ func (t *Team) CanUpdate(user *User, id int64) bool {
|
|||
return exists
|
||||
}
|
||||
|
||||
// CanDelete
|
||||
// CanDelete checks if a user can delete a team
|
||||
func (t *Team) CanDelete(user *User, id int64) bool {
|
||||
t.ID = id
|
||||
return t.IsAdmin(user)
|
||||
}
|
||||
|
||||
// IsAdmin
|
||||
// IsAdmin returns true when the user is admin of a team
|
||||
func (t *Team) IsAdmin(user *User) bool {
|
||||
exists, _ := x.Where("team_id = ?", t.ID).
|
||||
And("user_id = ?", user.ID).
|
||||
|
@ -33,6 +33,7 @@ func (t *Team) IsAdmin(user *User) bool {
|
|||
return exists
|
||||
}
|
||||
|
||||
// CanRead returns true if the user has read access to the team
|
||||
func (t *Team) CanRead(user *User) bool {
|
||||
// Check if the user is in the team
|
||||
exists, _ := x.Where("team_id = ?", t.ID).
|
||||
|
|
Loading…
Reference in a new issue