mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-30 20:55:17 +01:00
Push conversion of a todo to a project down.
Refactor the conversion of a todo to a project and move it from the TodosController to the Project model.
This commit is contained in:
parent
2911036ff7
commit
b01c7878d1
3 changed files with 27 additions and 7 deletions
|
|
@ -900,13 +900,10 @@ class TodosController < ApplicationController
|
|||
end
|
||||
|
||||
def convert_to_project
|
||||
@todo = current_user.todos.find_by_id(params[:id])
|
||||
@project = current_user.projects.new(:name => @todo.description, :description => @todo.notes,
|
||||
:default_context => @todo.context)
|
||||
|
||||
unless @project.invalid?
|
||||
@todo.destroy
|
||||
@project.save!
|
||||
todo = current_user.todos.find_by_id(params[:id])
|
||||
@project = Project.create_from_todo(todo)
|
||||
|
||||
if @project.valid?
|
||||
redirect_to project_url(@project)
|
||||
else
|
||||
flash[:error] = "Could not create project from todo: #{@project.errors.full_messages[0]}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue