fixed lint

This commit is contained in:
konrad 2018-07-16 08:45:38 +02:00 committed by kolaente
parent 7dc4cd2173
commit b11bd9f0b1
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
3 changed files with 5 additions and 2 deletions

View file

@ -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"`

View file

@ -1,5 +1,6 @@
package models
// Delete deletes a team
func (t *Team) Delete(id int64) (err error) {
// Check if the team exists

View file

@ -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).