|
@ -9,17 +9,24 @@ class Task |
|
|
property :id, Serial |
|
|
property :id, Serial |
|
|
property :name, String, required: true |
|
|
property :name, String, required: true |
|
|
property :completed_at, DateTime |
|
|
property :completed_at, DateTime |
|
|
|
|
|
belongs_to :list |
|
|
|
|
|
end |
|
|
|
|
|
class List |
|
|
|
|
|
include DataMapper::Resource |
|
|
|
|
|
property :id, Serial |
|
|
|
|
|
property :name, String, required: true |
|
|
|
|
|
has n, :tasks, :constraint => :destroy |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
DataMapper.finalize |
|
|
DataMapper.finalize |
|
|
|
|
|
|
|
|
get '/' do |
|
|
get '/' do |
|
|
@tasks = Task.all |
|
|
|
|
|
|
|
|
@lists = List.all(:order => [:name]) |
|
|
haml :index |
|
|
haml :index |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
post '/' do |
|
|
|
|
|
Task.create params[:task] |
|
|
|
|
|
|
|
|
post '/:id' do |
|
|
|
|
|
List.get(params[:id]).tasks.create params['task'] |
|
|
redirect '/' |
|
|
redirect '/' |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
@ -39,3 +46,13 @@ get '/:task' do |
|
|
@task = params[:task].split('-').join(' ').capitalize |
|
|
@task = params[:task].split('-').join(' ').capitalize |
|
|
# haml :task |
|
|
# haml :task |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
post '/new/list' do |
|
|
|
|
|
List.create params['list'] |
|
|
|
|
|
redirect '/' |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
delete '/list/:id' do |
|
|
|
|
|
List.get(params[:id]).destroy |
|
|
|
|
|
redirect '/' |
|
|
|
|
|
end |