1
0

feat: rename lists to projects

This commit is contained in:
kolaente
2022-11-13 17:07:01 +01:00
parent 80266d1383
commit 349e6a5905
113 changed files with 2753 additions and 2750 deletions

View File

@ -99,14 +99,14 @@ func getTrelloData(token string) (trelloData []*trello.Board, err error) {
log.Debugf("[Trello Migration] Got %d trello boards", len(trelloData))
for _, board := range trelloData {
log.Debugf("[Trello Migration] Getting lists for board %s", board.ID)
log.Debugf("[Trello Migration] Getting projects for board %s", board.ID)
board.Lists, err = board.GetLists(trello.Defaults())
if err != nil {
return
}
log.Debugf("[Trello Migration] Got %d lists for board %s", len(board.Lists), board.ID)
log.Debugf("[Trello Migration] Got %d projects for board %s", len(board.Lists), board.ID)
listMap := make(map[string]*trello.List, len(board.Lists))
for _, list := range board.Lists {
@ -161,27 +161,27 @@ func getTrelloData(token string) (trelloData []*trello.Board, err error) {
}
// Converts all previously obtained data from trello into the vikunja format.
// `trelloData` should contain all boards with their lists and cards respectively.
func convertTrelloDataToVikunja(trelloData []*trello.Board, token string) (fullVikunjaHierachie []*models.NamespaceWithListsAndTasks, err error) {
// `trelloData` should contain all boards with their projects and cards respectively.
func convertTrelloDataToVikunja(trelloData []*trello.Board, token string) (fullVikunjaHierachie []*models.NamespaceWithProjectsAndTasks, err error) {
log.Debugf("[Trello Migration] ")
fullVikunjaHierachie = []*models.NamespaceWithListsAndTasks{
fullVikunjaHierachie = []*models.NamespaceWithProjectsAndTasks{
{
Namespace: models.Namespace{
Title: "Imported from Trello",
},
Lists: []*models.ListWithTasksAndBuckets{},
Projects: []*models.ProjectWithTasksAndBuckets{},
},
}
var bucketID int64 = 1
log.Debugf("[Trello Migration] Converting %d boards to vikunja lists", len(trelloData))
log.Debugf("[Trello Migration] Converting %d boards to vikunja projects", len(trelloData))
for _, board := range trelloData {
list := &models.ListWithTasksAndBuckets{
List: models.List{
project := &models.ProjectWithTasksAndBuckets{
Project: models.Project{
Title: board.Name,
Description: board.Desc,
IsArchived: board.Closed,
@ -189,7 +189,7 @@ func convertTrelloDataToVikunja(trelloData []*trello.Board, token string) (fullV
}
// Background
// We're pretty much abusing the backgroundinformation field here - not sure if this is really better than adding a new property to the list
// We're pretty much abusing the backgroundinformation field here - not sure if this is really better than adding a new property to the project
if board.Prefs.BackgroundImage != "" {
log.Debugf("[Trello Migration] Downloading background %s for board %s", board.Prefs.BackgroundImage, board.ID)
buf, err := migration.DownloadFile(board.Prefs.BackgroundImage)
@ -197,7 +197,7 @@ func convertTrelloDataToVikunja(trelloData []*trello.Board, token string) (fullV
return nil, err
}
log.Debugf("[Trello Migration] Downloaded background %s for board %s", board.Prefs.BackgroundImage, board.ID)
list.BackgroundInformation = buf
project.BackgroundInformation = buf
} else {
log.Debugf("[Trello Migration] Board %s does not have a background image, not copying...", board.ID)
}
@ -291,23 +291,23 @@ func convertTrelloDataToVikunja(trelloData []*trello.Board, token string) (fullV
log.Debugf("[Trello Migration] Downloaded card attachment %s", attachment.ID)
}
list.Tasks = append(list.Tasks, &models.TaskWithComments{Task: *task})
project.Tasks = append(project.Tasks, &models.TaskWithComments{Task: *task})
}
list.Buckets = append(list.Buckets, bucket)
project.Buckets = append(project.Buckets, bucket)
bucketID++
}
log.Debugf("[Trello Migration] Converted all cards to tasks for board %s", board.ID)
fullVikunjaHierachie[0].Lists = append(fullVikunjaHierachie[0].Lists, list)
fullVikunjaHierachie[0].Projects = append(fullVikunjaHierachie[0].Projects, project)
}
return
}
// Migrate gets all tasks from trello for a user and puts them into vikunja
// @Summary Migrate all lists, tasks etc. from trello
// @Summary Migrate all projects, tasks etc. from trello
// @Description Migrates all projects, tasks, notes, reminders, subtasks and files from trello to vikunja.
// @tags migration
// @Accept json

View File

@ -44,9 +44,9 @@ func TestConvertTrelloToVikunja(t *testing.T) {
Name: "TestBoard",
Desc: "This is a description",
Closed: false,
Lists: []*trello.List{
Projects: []*trello.Project{
{
Name: "Test List 1",
Name: "Test Project 1",
Cards: []*trello.Card{
{
Name: "Test Card 1",
@ -77,9 +77,9 @@ func TestConvertTrelloToVikunja(t *testing.T) {
{
Name: "Test Card 2",
Pos: 124,
Checklists: []*trello.Checklist{
Checkprojects: []*trello.Checkproject{
{
Name: "Checklist 1",
Name: "Checkproject 1",
CheckItems: []trello.CheckItem{
{
State: "pending",
@ -92,7 +92,7 @@ func TestConvertTrelloToVikunja(t *testing.T) {
},
},
{
Name: "Checklist 2",
Name: "Checkproject 2",
CheckItems: []trello.CheckItem{
{
State: "pending",
@ -124,7 +124,7 @@ func TestConvertTrelloToVikunja(t *testing.T) {
},
},
{
Name: "Test List 2",
Name: "Test Project 2",
Cards: []*trello.Card{
{
Name: "Test Card 5",
@ -157,9 +157,9 @@ func TestConvertTrelloToVikunja(t *testing.T) {
{
Name: "TestBoard 2",
Closed: false,
Lists: []*trello.List{
Projects: []*trello.Project{
{
Name: "Test List 4",
Name: "Test Project 4",
Cards: []*trello.Card{
{
Name: "Test Card 634",
@ -172,9 +172,9 @@ func TestConvertTrelloToVikunja(t *testing.T) {
{
Name: "TestBoard Archived",
Closed: true,
Lists: []*trello.List{
Projects: []*trello.Project{
{
Name: "Test List 5",
Name: "Test Project 5",
Cards: []*trello.Card{
{
Name: "Test Card 63423",
@ -187,14 +187,14 @@ func TestConvertTrelloToVikunja(t *testing.T) {
}
trelloData[0].Prefs.BackgroundImage = "https://vikunja.io/testimage.jpg" // Using an image which we are hosting, so it'll still be up
expectedHierachie := []*models.NamespaceWithListsAndTasks{
expectedHierachie := []*models.NamespaceWithProjectsAndTasks{
{
Namespace: models.Namespace{
Title: "Imported from Trello",
},
Lists: []*models.ListWithTasksAndBuckets{
Projects: []*models.ProjectWithTasksAndBuckets{
{
List: models.List{
Project: models.Project{
Title: "TestBoard",
Description: "This is a description",
BackgroundInformation: bytes.NewBuffer(exampleFile),
@ -202,11 +202,11 @@ func TestConvertTrelloToVikunja(t *testing.T) {
Buckets: []*models.Bucket{
{
ID: 1,
Title: "Test List 1",
Title: "Test Project 1",
},
{
ID: 2,
Title: "Test List 2",
Title: "Test Project 2",
},
},
Tasks: []*models.TaskWithComments{
@ -244,12 +244,12 @@ func TestConvertTrelloToVikunja(t *testing.T) {
Title: "Test Card 2",
Description: `
## Checklist 1
## Checkproject 1
* [ ] Pending Task
* [x] Completed Task
## Checklist 2
## Checkproject 2
* [ ] Pending Task
* [ ] Another Pending Task`,
@ -315,13 +315,13 @@ func TestConvertTrelloToVikunja(t *testing.T) {
},
},
{
List: models.List{
Project: models.Project{
Title: "TestBoard 2",
},
Buckets: []*models.Bucket{
{
ID: 3,
Title: "Test List 4",
Title: "Test Project 4",
},
},
Tasks: []*models.TaskWithComments{
@ -335,14 +335,14 @@ func TestConvertTrelloToVikunja(t *testing.T) {
},
},
{
List: models.List{
Project: models.Project{
Title: "TestBoard Archived",
IsArchived: true,
},
Buckets: []*models.Bucket{
{
ID: 4,
Title: "Test List 5",
Title: "Test Project 5",
},
},
Tasks: []*models.TaskWithComments{