Skip to content

Commit

Permalink
fix backend lint
Browse files Browse the repository at this point in the history
as reported in https://drone.gitea.io/go-gitea/gitea/28939/1/4

use log.Error instead of log.Info

fix comments

fix eslint

fix goimport order

add migrations for project priorities

fix _repository.less lint errors

update swagger

fixes according to @6543 suggestions

s/NotInProjectID/ExcludeProjectID/g

update boards priority in a single transaction as per @zeripath

Co-authored-by: zeripath <art27@cantab.net>

update swagger

Clean up the indenting

Co-authored-by: zeripath <art27@cantab.net>

use tabs

Co-authored-by: zeripath <art27@cantab.net>

use tabs

add loadRepository as per @zeripath suggestion

move projects css to features/projects.less
as per @silverwind request
#12506 (review)

use transaction to update projects issues priorities
as per @zeripath suggestion
#12506 (comment)

make import fit on one line

make use of loadRepository

indent html properly
as per suggestion by @silverwind
#12506 (comment)

remove non-working code as per @zeripath suggestion
#12506 (comment)

remove non-used code
as per @zeripath suggestion
#12506 (comment)

fix syntax, remove content-type on request
#12506 (comment)

use closest instead of parent
as per @silverwind suggestion
#12506 (review)

use for instead of forEach because @silverwind

use for instead of forEach because @silverwind

#12506 (review)

use // falls through as per @silverwind

#12506 (comment)

listen to body keyup only on project page

#12506 (review)

Update models/project_board.go

Co-authored-by: Lauris BH <lauris@nix.lv>

move all issue related code to its own util file
and re-use those functions in index.js and projects.js
as per @silverwind and @zeripath

Update models/project_issue.go

Co-authored-by: 6543 <6543@obermui.de>

fix linting

Update web_src/js/features/issuesutil.js

Co-authored-by: silverwind <me@silverwind.io>

Update web_src/js/features/issuesutil.js

Co-authored-by: silverwind <me@silverwind.io>

Update web_src/js/features/issuesutil.js

Co-authored-by: silverwind <me@silverwind.io>

Update web_src/js/features/projects.js

Co-authored-by: silverwind <me@silverwind.io>

Update web_src/js/features/projects.js

Co-authored-by: silverwind <me@silverwind.io>

Update models/project_issue.go

Update models/issue.go

Co-authored-by: zeripath <art27@cantab.net>

Update web_src/js/features/issuesutil.js

Co-authored-by: silverwind <me@silverwind.io>

various js fix per @silverwind suggestions

various fixes according to @silverwind and @zeripath

use await for fetch when possible

specify table name as per @lafriks suggestion

specify table name as per @lafriks suggestion in more queries

#12506 (review)

#12506 (comment)

Update templates/repo/projects/view.tmpl

Co-authored-by: silverwind <me@silverwind.io>

Update templates/repo/projects/view.tmpl

Co-authored-by: silverwind <me@silverwind.io>

Update web_src/js/features/projects.js

Co-authored-by: silverwind <me@silverwind.io>

fix project_issue table name in query
make another fetch async as per @silverwind

Update models/project.go

Co-authored-by: Lauris BH <lauris@nix.lv>

Update models/project.go

Co-authored-by: Lauris BH <lauris@nix.lv>

more and rename UpdateBoards functions as per @6543

Update models/project.go

Co-authored-by: Lauris BH <lauris@nix.lv>

Update models/project.go

Co-authored-by: Lauris BH <lauris@nix.lv>

add / to route

fixup! fix backend lint as reported in https://drone.gitea.io/go-gitea/gitea/28939/1/4

Update models/project.go

Co-authored-by: zeripath <art27@cantab.net>

Update routers/repo/issue.go

Co-authored-by: zeripath <art27@cantab.net>

Update web_src/less/features/projects.less

Co-authored-by: silverwind <me@silverwind.io>

fix uneeded column in query and remove css class
as suggested by @silverwind

Update models/project.go

Co-authored-by: Lauris BH <lauris@nix.lv>

add X to close sidebar and other css suggestions by @silverwind

add emoji to project issue titles

use issue.* instead as suggested by @zeripath
still waiting for xorm v1.0.5 to update go.mod

fix project_issue query for now

fix card details css
  • Loading branch information
patcito committed Nov 10, 2020
1 parent 2fd630c commit ee388a2
Show file tree
Hide file tree
Showing 23 changed files with 2,019 additions and 1,870 deletions.
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/ethantkoenig/rupture v0.0.0-20181029165146-c3b3b810dc77 h1:ZLWiTTzTUBb0WEXUxobYI/RxULIzOoIP7pgfDd4p1cw=
github.com/ethantkoenig/rupture v0.0.0-20181029165146-c3b3b810dc77/go.mod h1:MkKY/CB98aVE4VxO63X5vTQKUgcn+3XP15LMASe3lYs=
github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51 h1:0JZ+dUmQeA8IIVUMzysrX4/AKuQwWhV2dYQuPZdvdSQ=
github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64=
Expand Down Expand Up @@ -655,6 +656,7 @@ github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0f
github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jackc/puddle v1.1.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jarcoal/httpmock v0.0.0-20180424175123-9c70cfe4a1da/go.mod h1:ks+b9deReOc7jgqp+e7LuFiCBH6Rm5hL32cLcEAArb4=
github.com/jaytaylor/html2text v0.0.0-20200412013138-3577fbdbcff7 h1:g0fAGBisHaEQ0TRq1iBvemFRf+8AEWEmBESSiWB3Vsc=
github.com/jaytaylor/html2text v0.0.0-20200412013138-3577fbdbcff7/go.mod h1:CVKlgaMiht+LXvHG173ujK6JUhZXKb2u/BQtjPDIvyk=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
Expand Down Expand Up @@ -684,6 +686,7 @@ github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7V
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4=
github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd h1:Coekwdh0v2wtGp9Gmz1Ze3eVRAWJMLokvN3QjdzCHLY=
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
Expand Down Expand Up @@ -1025,6 +1028,7 @@ github.com/spf13/viper v1.7.0 h1:xVKxvI7ouOI5I+U9s2eeiUfMaWBVoXA3AWskkrqK0VM=
github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
github.com/spf13/viper v1.7.1 h1:pM5oEahlgWv/WnHXpgbKz7iLIxRf65tye2Ci+XFK5sk=
github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf h1:pvbZ0lM0XWPBqUKqFU8cmavspvIl9nulOYwdy6IFRRo=
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf/go.mod h1:RJID2RhlZKId02nZ62WenDCkgHFerpIOmW0iT7GKmXM=
github.com/steveyen/gtreap v0.1.0 h1:CjhzTa274PyJLJuMZwIzCO1PfC00oRa8d1Kc78bFXJM=
github.com/steveyen/gtreap v0.1.0/go.mod h1:kl/5J7XbrOmlIbYIXdRHDDE5QxHqpk0cmkT7Z4dM9/Y=
Expand Down Expand Up @@ -1069,6 +1073,7 @@ github.com/unknwon/com v1.0.1/go.mod h1:tOOxU81rwgoCLoOVVPHb6T/wt8HZygqH5id+GNnl
github.com/unknwon/i18n v0.0.0-20190805065654-5c6446a380b6/go.mod h1:+5rDk6sDGpl3azws3O+f+GpFSyN9GVr0K8cvQLQM2ZQ=
github.com/unknwon/i18n v0.0.0-20200823051745-09abd91c7f2c h1:679/gJXwrsHC3RATr0YYjZvDMJPYN7W9FGSGNoLmKxM=
github.com/unknwon/i18n v0.0.0-20200823051745-09abd91c7f2c/go.mod h1:+5rDk6sDGpl3azws3O+f+GpFSyN9GVr0K8cvQLQM2ZQ=
github.com/unknwon/paginater v0.0.0-20200328080006-042474bd0eae h1:ihaXiJkaca54IaCSnEXtE/uSZOmPxKZhDfVLrzZLFDs=
github.com/unknwon/paginater v0.0.0-20200328080006-042474bd0eae/go.mod h1:1fdkY6xxl6ExVs2QFv7R0F5IRZHKA8RahhB9fMC9RvM=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
Expand Down
30 changes: 20 additions & 10 deletions models/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/markup"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/structs"
api "code.gitea.io/gitea/modules/structs"
Expand Down Expand Up @@ -63,6 +64,7 @@ type Issue struct {
Reactions ReactionList `xorm:"-"`
TotalTrackedTime int64 `xorm:"-"`
Assignees []*User `xorm:"-"`
ProjectIssueID ProjectIssue

// IsLocked limits commenting abilities to users on an issue
// with write access
Expand Down Expand Up @@ -1100,9 +1102,10 @@ type IssuesOptions struct {
ExcludedLabelNames []string
SortType string
IssueIDs []int64
NotInProjectID int64
ExcludeProjectID int64
// prioritize issues from this repo
PriorityRepoID int64
PriorityRepoID int64
RenderEmojiTitle util.OptionalBool
}

// sortIssuesSession sort an issues-related session based on the provided
Expand Down Expand Up @@ -1181,20 +1184,19 @@ func (opts *IssuesOptions) setupSession(sess *xorm.Session) {

if opts.ProjectID > 0 {
sess.Join("INNER", "project_issue", "issue.id = project_issue.issue_id").
And("project_issue.project_id=?", opts.ProjectID).OrderBy("priority")
And("project_issue.project_id=?", opts.ProjectID).OrderBy("`project_issue`.priority")
}

if opts.ProjectBoardID != 0 {
if opts.ProjectBoardID > 0 {
sess.In("issue.id", builder.Select("issue_id").From("project_issue").Where(builder.Eq{"project_board_id": opts.ProjectBoardID}).OrderBy("priority"))
sess.In("issue.id", builder.Select("issue_id").From("project_issue").Where(builder.Eq{"project_board_id": opts.ProjectBoardID}).OrderBy("`project_issue`.priority"))
} else {
sess.In("issue.id", builder.Select("issue_id").From("project_issue").Where(builder.Eq{"project_board_id": 0}).OrderBy("priority"))
sess.In("issue.id", builder.Select("issue_id").From("project_issue").Where(builder.Eq{"project_board_id": 0}).OrderBy("`project_issue`.priority"))
}
}

if opts.NotInProjectID != 0 {
if opts.NotInProjectID > 0 {
sess.NotIn("issue.id", builder.Select("issue_id").From("project_issue").Where(builder.Eq{"project_id": opts.NotInProjectID}).OrderBy("priority"))
}
if opts.ExcludeProjectID != 0 {
sess.NotIn("issue.id", builder.Select("issue_id").From("project_issue").Where(builder.Eq{"project_id": opts.ExcludeProjectID}).OrderBy("`project_issue`.priority"))
}

switch opts.IsPull {
Expand Down Expand Up @@ -1286,7 +1288,15 @@ func Issues(opts *IssuesOptions) ([]*Issue, error) {
if err := IssueList(issues).LoadAttributes(); err != nil {
return nil, fmt.Errorf("LoadAttributes: %v", err)
}

if opts.RenderEmojiTitle == util.OptionalBoolTrue {
var issuesWithEmojis []*Issue
for _, issue := range issues {
title := string(markup.RenderEmoji(issue.Title))
issue.Title = title
issuesWithEmojis = append(issuesWithEmojis, issue)
}
return issuesWithEmojis, nil
}
return issues, nil
}

Expand Down
2 changes: 2 additions & 0 deletions models/migrations/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ var migrations = []Migration{
NewMigration("ensure repo topics are up-to-date", fixRepoTopics),
// v158 -> v159
NewMigration("code comment replies should have the commitID of the review they are replying to", updateCodeCommentReplies),
// v159 -> v160
NewMigration("Add projects boards and issues priorities", addProjectsIssuesBoardsPriority),
}

// GetCurrentDBVersion returns the current db version
Expand Down
26 changes: 26 additions & 0 deletions models/migrations/v159.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

package migrations

import (
"xorm.io/xorm"
)

func addProjectsIssuesBoardsPriority(x *xorm.Engine) error {
// ProjectIssue saves relation from issue to a project
type ProjectIssue struct {
Priority int `xorm:"NOT NULL DEFAULT 0"`
}

if err := x.Sync2(new(ProjectIssue)); err != nil {
return err
}

type ProjectBoard struct {
Priority int `xorm:"NOT NULL DEFAULT 0"`
}

return x.Sync2(new(ProjectBoard))
}
51 changes: 12 additions & 39 deletions models/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,50 +308,23 @@ func deleteProjectByID(e Engine, id int64) error {
return updateRepositoryProjectCount(e, p.RepoID)
}

// Update given boards priority for a project
func UpdateBoards(boards []ProjectBoard) error {
for _, board := range boards {
if _, err := x.ID(board.ID).Cols("priority").Update(&board); err != nil {
log.Info("failed updating board priorities %s", err)
return err
}

}
return nil
// LoadRepository loads repository of a given project
func (p *Project) LoadRepository() error {
return p.loadRepository(x)
}

// Update given issue priority and column
func UpdateBoardIssues(issues []ProjectIssue) (error, []ProjectIssue) {
var updatedIssues []ProjectIssue
for _, pissue := range issues {
if pissue.ID != 0 {
if _, err := x.ID(pissue.ID).Cols("priority", "project_board_id").Update(&pissue); err != nil {
log.Info("failed updating cards priorities %s", err)
return err, updatedIssues
} else {
updatedIssues = append(updatedIssues, pissue)
}
} else {
if _, err := x.Insert(&pissue); err != nil {
log.Info("failed inserting cards priorities %s", err)
return err, updatedIssues
} else {
updatedIssues = append(updatedIssues, pissue)
}
}
// loadRepository loads repository of a given project
func (p *Project) loadRepository(e Engine) error {
if p.Repo != nil {
return nil
}
return nil, updatedIssues
}

func (p *Project) LoadRepository() error {
var repo = Repository{}
if p.Type == ProjectTypeRepository {
_, err := x.ID(p.RepoID).Get(&repo)
p.Repo = &repo
if err != nil {
log.Info("failed getting repo %w", err)
repo := &Repository{}
if _, err := e.ID(p.RepoID).Get(repo); err != nil {
log.Info("failed getting repo %v", err)
return err
}
return err
p.Repo = repo
}
return nil
}
54 changes: 36 additions & 18 deletions models/project_board.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type ProjectBoard struct {
ID int64 `xorm:"pk autoincr"`
Title string
Default bool `xorm:"NOT NULL DEFAULT false"` // issues not assigned to a specific board will be assigned to this board
Priority int
Priority int `xorm:"NOT NULL DEFAULT 0"`

ProjectID int64 `xorm:"INDEX NOT NULL"`
CreatorID int64 `xorm:"NOT NULL"`
Expand Down Expand Up @@ -190,7 +190,7 @@ func GetUncategorizedBoard(projectID int64) (*ProjectBoard, error) {
}, nil
}

// LoadIssues load issues assigned to this board
// LoadProjectIssues load project issues assigned to this board
func (b *ProjectBoard) LoadProjectIssues() ([]*ProjectIssue, error) {
var boardID int64
if !b.Default {
Expand All @@ -200,25 +200,27 @@ func (b *ProjectBoard) LoadProjectIssues() ([]*ProjectIssue, error) {
// Issues without ProjectBoardID
boardID = 0
}
var projectIssuesDB []*ProjectIssue
var projectIssues []*ProjectIssue
err := x.Table("project_issue").Where("project_board_id = ? and project_id =?",
boardID, b.ProjectID).
OrderBy("priority").Find(&projectIssuesDB)
for _, projectIssue := range projectIssuesDB {
if issue, err := getIssueByID(x, projectIssue.IssueID); err != nil {
log.Info("failed getting projectIssue's issue %v\n", err)
} else {
issue.LoadLabels()
issue.LoadMilestone()
issue.loadAssignees(x)
projectIssue.Issue = issue
projectIssues = append(projectIssues, projectIssue)
}
var issues []*Issue
if err := x.Table("issue").
Cols("issue.id, issue.repo_id, issue.index, issue.poster_id,issue.name,issue.milestone_id,issue.is_closed,issue.is_pull,issue.created_unix,issue.updated_unix, project_issue.id as project_issue_id, project_issue.project_id as project_issue_project_id, project_issue.project_board_id as project_issue_project_board_id").
Join("INNER", "project_issue", "issue.id = project_issue.issue_id").
Where("project_board_id = ? and project_id =?",
boardID, b.ProjectID).
OrderBy("`project_issue`.priority").Find(&issues); err != nil {
log.Error("LoadAttributes: %v", err)
}

if err := IssueList(issues).LoadAttributes(); err != nil {
log.Error("LoadAttributes: %v", err)
}

b.ProjectIssues = projectIssues
return projectIssues, err
for _, issue := range issues {
projectIssue := issue.ProjectIssueID
projectIssue.Issue = issue
projectIssues = append(projectIssues, &projectIssue)
}
return projectIssues, nil
}

// LoadIssues load issues assigned to the boards
Expand All @@ -232,3 +234,19 @@ func (bs ProjectBoardList) LoadIssues() error {
}
return nil
}

// UpdateBoardsPriority updates boards priority for a project
func UpdateBoardsPriority(boards []ProjectBoard) error {
sess := x.NewSession()
if err := sess.Begin(); err != nil {
return err
}
defer sess.Close()
for _, board := range boards {
if _, err := sess.ID(board.ID).Cols("priority").Update(&board); err != nil {
log.Info("failed updating board priorities %s", err)
return err
}
}
return sess.Commit()
}
55 changes: 43 additions & 12 deletions models/project_issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@ import (
"fmt"

"code.gitea.io/gitea/modules/log"

"xorm.io/xorm"
)

// ProjectIssue saves relation from issue to a project
type ProjectIssue struct {
ID int64 `xorm:"pk autoincr"`
IssueID int64 `xorm:"INDEX"`
ProjectID int64 `xorm:"INDEX"`
IssueTitle string `xorm:"-"`
IssueIsPull bool `xorm:"-"`
Priority int
Issue *Issue `xorm:"-"`
ID int64 `xorm:"pk autoincr"`
IssueID int64 `xorm:"INDEX"`
ProjectID int64 `xorm:"INDEX"`
Priority int `xorm:"NOT NULL DEFAULT 0"`
Issue *Issue `xorm:"-"`

// If 0, then it has not been added to a specific board in the project
ProjectBoardID int64 `xorm:"INDEX"`
Expand Down Expand Up @@ -69,12 +68,12 @@ func (i *Issue) projectID(e Engine) int64 {
return ip.ProjectID
}

// ProjectBoardID return project board id if issue was assigned to one
func (i *Issue) ProjectBoardID() int64 {
return i.projectBoardID(x)
// LoadProjectBoardID return project board id if issue was assigned to one
func (i *Issue) LoadProjectBoardID() int64 {
return i.loadProjectBoardID(x)
}

func (i *Issue) projectBoardID(e Engine) int64 {
func (i *Issue) loadProjectBoardID(e Engine) int64 {
var ip ProjectIssue
has, err := e.Where("issue_id=?", i.ID).Get(&ip)
if err != nil || !has {
Expand Down Expand Up @@ -146,7 +145,6 @@ func ChangeProjectAssign(issue *Issue, doer *User, newProjectID int64) error {
func addUpdateIssueProject(e *xorm.Session, issue *Issue, doer *User, newProjectID int64) error {
oldProjectID := issue.projectID(e)
if _, err := e.Where("project_issue.issue_id=?", issue.ID).Delete(&ProjectIssue{}); err != nil {
log.Info("failed deleting project issue %w", err)
return err
}

Expand Down Expand Up @@ -222,3 +220,36 @@ func (pb *ProjectBoard) removeIssues(e Engine) error {
_, err := e.Exec("UPDATE `project_issue` SET project_board_id = 0 WHERE project_board_id = ? ", pb.ID)
return err
}

// UpdateBoardIssuesPriority update given board issue priority
func UpdateBoardIssuesPriority(issues []ProjectIssue) ([]ProjectIssue, error) {
sess := x.NewSession()
if err := sess.Begin(); err != nil {
var updatedIssues []ProjectIssue
return updatedIssues, err
}
defer sess.Close()
var updatedIssues []ProjectIssue
for _, pissue := range issues {
if pissue.ID != 0 {
if _, err := sess.ID(pissue.ID).Cols("priority", "project_board_id").Update(&pissue); err != nil {
log.Info("failed updating cards priorities %s", err)
return updatedIssues, err
}
updatedIssues = append(updatedIssues, pissue)
} else {
var existingIssue ProjectIssue
if found, err := sess.Where("issue_id = ? and project_id = ?", pissue.IssueID, pissue.ProjectID).
Get(&existingIssue); err != nil {
log.Error("failed finding issue %s", err)
} else if !found {
if _, err := sess.Insert(&pissue); err != nil {
log.Info("failed inserting cards priorities %s", err)
return updatedIssues, err
}
updatedIssues = append(updatedIssues, pissue)
}
}
}
return updatedIssues, sess.Commit()
}
2 changes: 1 addition & 1 deletion modules/auth/repo_form.go
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ func (f *DeadlineForm) Validate(ctx *macaron.Context, errs binding.Errors) bindi

// UpdateBoardPriorityForm form for updating cards on drag and drop
type UpdateBoardPriorityForm struct {
Boards []models.ProjectBoard `form:"boards" json:"boards"`
Boards []models.ProjectBoard
}

// Validate validates the fields
Expand Down
Loading

0 comments on commit ee388a2

Please sign in to comment.