fmt & lint
All checks were successful
the build was successful

This commit is contained in:
kolaente 2018-10-31 12:41:43 +01:00
parent 6d0ed773e3
commit 8f11b49d01
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
17 changed files with 35 additions and 35 deletions

View File

@ -8,7 +8,7 @@ type List struct {
OwnerID int64 `xorm:"int(11) INDEX" json:"-"`
NamespaceID int64 `xorm:"int(11) INDEX" json:"-" param:"namespace"`
Owner User `xorm:"-" json:"owner"`
Owner User `xorm:"-" json:"owner"`
Tasks []*ListTask `xorm:"-" json:"tasks"`
Created int64 `xorm:"created" json:"created"`
@ -98,7 +98,7 @@ func (l *List) GetSimpleByID() (err error) {
return
}
// Adds owner user objects and list tasks to all lists in the slice
// AddListDetails adds owner user objects and list tasks to all lists in the slice
func AddListDetails(lists []*List) (err error) {
var listIDs []int64
var ownerIDs []int64

View File

@ -2,9 +2,9 @@ package models
// ListUser represents a list <-> user relation
type ListUser struct {
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"namespace"`
UserID int64 `xorm:"int(11) not null INDEX" json:"user_id" param:"user"`
ListID int64 `xorm:"int(11) not null INDEX" json:"list_id" param:"list"`
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"namespace"`
UserID int64 `xorm:"int(11) not null INDEX" json:"user_id" param:"user"`
ListID int64 `xorm:"int(11) not null INDEX" json:"list_id" param:"list"`
Right UserRight `xorm:"int(11) INDEX" json:"right"`
Created int64 `xorm:"created" json:"created"`
@ -20,6 +20,6 @@ func (ListUser) TableName() string {
}
type userWithRight struct {
User `xorm:"extends"`
Right UserRight `json:"right"`
User `xorm:"extends"`
Right UserRight `json:"right"`
}

View File

@ -4,7 +4,7 @@ package models
func (ul *ListUser) Create(u *User) (err error) {
// Check if the right is valid
if err := ul.Right.IsValid(); err != nil {
if err := ul.Right.isValid(); err != nil {
return err
}

View File

@ -4,7 +4,7 @@ package models
func (lu *ListUser) Update() (err error) {
// Check if the right is valid
if err := lu.Right.IsValid(); err != nil {
if err := lu.Right.isValid(); err != nil {
return err
}

View File

@ -2,9 +2,9 @@ package models
// NamespaceUser represents a namespace <-> user relation
type NamespaceUser struct {
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"namespace"`
UserID int64 `xorm:"int(11) not null INDEX" json:"user_id" param:"user"`
NamespaceID int64 `xorm:"int(11) not null INDEX" json:"namespace_id" param:"namespace"`
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"namespace"`
UserID int64 `xorm:"int(11) not null INDEX" json:"user_id" param:"user"`
NamespaceID int64 `xorm:"int(11) not null INDEX" json:"namespace_id" param:"namespace"`
Right UserRight `xorm:"int(11) INDEX" json:"right"`
Created int64 `xorm:"created" json:"created"`

View File

@ -7,7 +7,7 @@ func (un *NamespaceUser) Create(u *User) (err error) {
un.ID = 0
// Check if the right is valid
if err := un.Right.IsValid(); err != nil {
if err := un.Right.isValid(); err != nil {
return err
}

View File

@ -4,7 +4,7 @@ package models
func (nu *NamespaceUser) Update() (err error) {
// Check if the right is valid
if err := nu.Right.IsValid(); err != nil {
if err := nu.Right.isValid(); err != nil {
return err
}

View File

@ -2,9 +2,9 @@ package models
// TeamList defines the relation between a team and a list
type TeamList struct {
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id"`
TeamID int64 `xorm:"int(11) not null INDEX" json:"team_id" param:"team"`
ListID int64 `xorm:"int(11) not null INDEX" json:"list_id" param:"list"`
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id"`
TeamID int64 `xorm:"int(11) not null INDEX" json:"team_id" param:"team"`
ListID int64 `xorm:"int(11) not null INDEX" json:"list_id" param:"list"`
Right TeamRight `xorm:"int(11) INDEX" json:"right"`
Created int64 `xorm:"created" json:"created"`
@ -20,6 +20,6 @@ func (TeamList) TableName() string {
}
type teamWithRight struct {
Team `xorm:"extends"`
Right TeamRight `json:"right"`
Team `xorm:"extends"`
Right TeamRight `json:"right"`
}

View File

@ -4,7 +4,7 @@ package models
func (tl *TeamList) Create(doer *User) (err error) {
// Check if the rights are valid
if err = tl.Right.IsValid(); err != nil {
if err = tl.Right.isValid(); err != nil {
return
}

View File

@ -4,7 +4,7 @@ package models
func (tl *TeamList) Update() (err error) {
// Check if the right is valid
if err := tl.Right.IsValid(); err != nil {
if err := tl.Right.isValid(); err != nil {
return err
}

View File

@ -2,9 +2,9 @@ package models
// TeamNamespace defines the relationship between a Team and a Namespace
type TeamNamespace struct {
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id"`
TeamID int64 `xorm:"int(11) not null INDEX" json:"team_id" param:"team"`
NamespaceID int64 `xorm:"int(11) not null INDEX" json:"namespace_id" param:"namespace"`
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id"`
TeamID int64 `xorm:"int(11) not null INDEX" json:"team_id" param:"team"`
NamespaceID int64 `xorm:"int(11) not null INDEX" json:"namespace_id" param:"namespace"`
Right TeamRight `xorm:"int(11) INDEX" json:"right"`
Created int64 `xorm:"created" json:"created"`

View File

@ -4,7 +4,7 @@ package models
func (tn *TeamNamespace) Create(doer *User) (err error) {
// Check if the rights are valid
if err = tn.Right.IsValid(); err != nil {
if err = tn.Right.isValid(); err != nil {
return
}

View File

@ -4,7 +4,7 @@ package models
func (tl *TeamNamespace) Update() (err error) {
// Check if the right is valid
if err := tl.Right.IsValid(); err != nil {
if err := tl.Right.isValid(); err != nil {
return err
}

View File

@ -18,7 +18,7 @@ const (
TeamRightAdmin
)
func (r TeamRight) IsValid() error {
func (r TeamRight) isValid() error {
if r != TeamRightAdmin && r != TeamRightRead && r != TeamRightWrite {
return ErrInvalidTeamRight{r}
}

View File

@ -7,7 +7,7 @@ type Team struct {
Description string `xorm:"varchar(250)" json:"description"`
CreatedByID int64 `xorm:"int(11) not null INDEX" json:"-"`
CreatedBy User `xorm:"-" json:"created_by"`
CreatedBy User `xorm:"-" json:"created_by"`
Members []*TeamUser `xorm:"-" json:"members"`
Created int64 `xorm:"created" json:"created"`
@ -56,8 +56,8 @@ func (TeamMember) TableName() string {
// TeamUser is the team member type
type TeamUser struct {
User `xorm:"extends"`
Admin bool `json:"admin"`
User `xorm:"extends"`
Admin bool `json:"admin"`
}
// GetTeamByID gets a team by its ID

View File

@ -72,14 +72,14 @@ func TestTeam_Create(t *testing.T) {
}
func TestIsErrInvalidTeamRight(t *testing.T) {
assert.NoError(t, TeamRightAdmin.IsValid())
assert.NoError(t, TeamRightRead.IsValid())
assert.NoError(t, TeamRightWrite.IsValid())
assert.NoError(t, TeamRightAdmin.isValid())
assert.NoError(t, TeamRightRead.isValid())
assert.NoError(t, TeamRightWrite.isValid())
// Check invalid
var tr TeamRight
tr = 938
err := tr.IsValid()
err := tr.isValid()
assert.Error(t, err)
assert.True(t, IsErrInvalidTeamRight(err))
}

View File

@ -18,7 +18,7 @@ const (
UserRightAdmin
)
func (r UserRight) IsValid() error {
func (r UserRight) isValid() error {
if r != UserRightAdmin && r != UserRightRead && r != UserRightWrite {
return ErrInvalidUserRight{r}
}