fix(views): lint
This commit is contained in:
parent
f3cdd7d15f
commit
30b41bd143
@ -17,8 +17,9 @@
|
|||||||
package migration
|
package migration
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"src.techknowlogick.com/xormigrate"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"src.techknowlogick.com/xormigrate"
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ func (task20240314214802) TableName() string {
|
|||||||
func init() {
|
func init() {
|
||||||
migrations = append(migrations, &xormigrate.Migration{
|
migrations = append(migrations, &xormigrate.Migration{
|
||||||
ID: "20240314214802",
|
ID: "20240314214802",
|
||||||
Description: "make task position seperate",
|
Description: "make task position separate",
|
||||||
Migrate: func(tx *xorm.Engine) error {
|
Migrate: func(tx *xorm.Engine) error {
|
||||||
err := tx.Sync2(taskPositions20240314214802{})
|
err := tx.Sync2(taskPositions20240314214802{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -121,7 +121,7 @@ func getDefaultBucketID(s *xorm.Session, view *ProjectView) (bucketID int64, err
|
|||||||
// @Success 200 {array} models.Bucket "The buckets"
|
// @Success 200 {array} models.Bucket "The buckets"
|
||||||
// @Failure 500 {object} models.Message "Internal server error"
|
// @Failure 500 {object} models.Message "Internal server error"
|
||||||
// @Router /projects/{id}/views/{view}/buckets [get]
|
// @Router /projects/{id}/views/{view}/buckets [get]
|
||||||
func (b *Bucket) ReadAll(s *xorm.Session, auth web.Auth, search string, page int, perPage int) (result interface{}, resultCount int, numberOfTotalItems int64, err error) {
|
func (b *Bucket) ReadAll(s *xorm.Session, auth web.Auth, _ string, _ int, _ int) (result interface{}, resultCount int, numberOfTotalItems int64, err error) {
|
||||||
|
|
||||||
view, err := GetProjectViewByIDAndProject(s, b.ProjectViewID, b.ProjectID)
|
view, err := GetProjectViewByIDAndProject(s, b.ProjectViewID, b.ProjectID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -246,6 +246,7 @@ func duplicateViews(s *xorm.Session, pd *ProjectDuplicate, doer web.Auth, taskMa
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, err = s.Insert(&taskPositions)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,10 +17,11 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"code.vikunja.io/web"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"code.vikunja.io/web"
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -58,7 +59,7 @@ func (p *ProjectViewKind) UnmarshalJSON(bytes []byte) error {
|
|||||||
case "kanban":
|
case "kanban":
|
||||||
*p = ProjectViewKindKanban
|
*p = ProjectViewKindKanban
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("unkown project view kind: %s", value)
|
return fmt.Errorf("unknown project view kind: %s", value)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -107,7 +108,7 @@ func (p *BucketConfigurationModeKind) UnmarshalJSON(bytes []byte) error {
|
|||||||
case "filter":
|
case "filter":
|
||||||
*p = BucketConfigurationModeFilter
|
*p = BucketConfigurationModeFilter
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("unkown bucket configuration mode kind: %s", value)
|
return fmt.Errorf("unknown bucket configuration mode kind: %s", value)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -236,7 +237,7 @@ func (p *ProjectView) ReadOne(s *xorm.Session, _ web.Auth) (err error) {
|
|||||||
// @Failure 403 {object} web.HTTPError "The user does not have access to the project view"
|
// @Failure 403 {object} web.HTTPError "The user does not have access to the project view"
|
||||||
// @Failure 500 {object} models.Message "Internal error"
|
// @Failure 500 {object} models.Message "Internal error"
|
||||||
// @Router /projects/{project}/views/{id} [delete]
|
// @Router /projects/{project}/views/{id} [delete]
|
||||||
func (p *ProjectView) Delete(s *xorm.Session, a web.Auth) (err error) {
|
func (p *ProjectView) Delete(s *xorm.Session, _ web.Auth) (err error) {
|
||||||
_, err = s.
|
_, err = s.
|
||||||
Where("id = ? AND project_id = ?", p.ID, p.ProjectID).
|
Where("id = ? AND project_id = ?", p.ID, p.ProjectID).
|
||||||
Delete(&ProjectView{})
|
Delete(&ProjectView{})
|
||||||
|
@ -22,37 +22,25 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (p *ProjectView) CanRead(s *xorm.Session, a web.Auth) (bool, int, error) {
|
func (p *ProjectView) CanRead(s *xorm.Session, a web.Auth) (bool, int, error) {
|
||||||
pp, err := p.getProject(s)
|
pp := p.getProject()
|
||||||
if err != nil {
|
|
||||||
return false, 0, err
|
|
||||||
}
|
|
||||||
return pp.CanRead(s, a)
|
return pp.CanRead(s, a)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ProjectView) CanDelete(s *xorm.Session, a web.Auth) (bool, error) {
|
func (p *ProjectView) CanDelete(s *xorm.Session, a web.Auth) (bool, error) {
|
||||||
pp, err := p.getProject(s)
|
pp := p.getProject()
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
return pp.CanUpdate(s, a)
|
return pp.CanUpdate(s, a)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ProjectView) CanUpdate(s *xorm.Session, a web.Auth) (bool, error) {
|
func (p *ProjectView) CanUpdate(s *xorm.Session, a web.Auth) (bool, error) {
|
||||||
pp, err := p.getProject(s)
|
pp := p.getProject()
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
return pp.CanUpdate(s, a)
|
return pp.CanUpdate(s, a)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ProjectView) CanCreate(s *xorm.Session, a web.Auth) (bool, error) {
|
func (p *ProjectView) CanCreate(s *xorm.Session, a web.Auth) (bool, error) {
|
||||||
pp, err := p.getProject(s)
|
pp := p.getProject()
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
return pp.CanUpdate(s, a)
|
return pp.CanUpdate(s, a)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ProjectView) getProject(s *xorm.Session) (pp *Project, err error) {
|
func (p *ProjectView) getProject() (pp *Project) {
|
||||||
return &Project{ID: p.ProjectID}, nil
|
return &Project{ID: p.ProjectID}
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,9 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"code.vikunja.io/web"
|
|
||||||
"math"
|
"math"
|
||||||
|
|
||||||
|
"code.vikunja.io/web"
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -932,6 +932,9 @@ func (t *Task) Update(s *xorm.Session, a web.Auth) (err error) {
|
|||||||
Where(builder.Eq{"project_id": t.ProjectID}),
|
Where(builder.Eq{"project_id": t.ProjectID}),
|
||||||
).
|
).
|
||||||
Find(&buckets)
|
Find(&buckets)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
for _, view := range views {
|
for _, view := range views {
|
||||||
// Only update the bucket when the current view
|
// Only update the bucket when the current view
|
||||||
|
Loading…
x
Reference in New Issue
Block a user