mirror of
https://github.com/TracksApp/tracks.git
synced 2026-03-04 03:50: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
|
|
@ -47,6 +47,21 @@ class Project < ActiveRecord::Base
|
|||
NullProject.new
|
||||
end
|
||||
|
||||
def self.create_from_todo(todo)
|
||||
project = Project.new(:name => todo.description,
|
||||
:description => todo.notes,
|
||||
:default_context => todo.context)
|
||||
|
||||
project.user = todo.user
|
||||
|
||||
if project.valid?
|
||||
todo.destroy
|
||||
project.save!
|
||||
end
|
||||
|
||||
project
|
||||
end
|
||||
|
||||
def hide_todos
|
||||
todos.each do |t|
|
||||
unless t.completed? || t.deferred?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue