Browse files

Merge branch 'master' of github.com:machida/frontline

  • Loading branch information...
2 parents df1d900 + b931304 commit c22136b2216284734c34507e3ce7e3cb4052dca1 teppei machida committed May 19, 2012
View
31 app/controllers/tasks_controller.rb
@@ -68,15 +68,12 @@ def create
#
# # DELETE /tasks/1
# # DELETE /tasks/1.json
- # def destroy
- # @task = Task.find(params[:id])
- # @task.destroy
- #
- # respond_to do |format|
- # format.html { redirect_to tasks_url }
- # format.json { head :no_content }
- # end
- # end
+ def destroy
+ @task = current_user.tasks.find(params[:id])
+ @party = @task.party
+ @task.destroy
+ respond_with @task
+ end
def start
@task = current_user.tasks.find(params[:id])
@@ -105,4 +102,20 @@ def finish
@party = @task.party
respond_with @task
end
+
+ def help
+ @task = current_user.tasks.find(params[:id])
+ @party = @task.party
+ @task.toggle!(:help)
+ respond_with @task
+ end
+
+ def redo
+ @task = current_user.tasks.find(params[:id])
+ @task.state = "backlog"
+ @task.finished_at = nil
+ @task.save
+ @party = @task.party
+ respond_with @task
+ end
end
View
3 app/helpers/application_helper.rb
@@ -1,2 +1,5 @@
module ApplicationHelper
+ def nl2br(str)
+ sanitize str.gsub(/\r\n|\r|\n/, "<br />"), tags: "br"
+ end
end
View
3 app/helpers/tasks_helper.rb
@@ -1,2 +1,5 @@
module TasksHelper
+ def help_message(task)
+ task.help ? "solve" : "help"
+ end
end
View
2 app/models/join.rb
@@ -1,6 +1,6 @@
# encoding: utf-8
class Join < ActiveRecord::Base
- attr_accessible :party_id, :user_id, :state, :end_hour, :end_min
+ attr_accessible :party_id, :user_id, :state, :end_hour, :end_min, :help
belongs_to :party
belongs_to :user
View
4 app/models/party.rb
@@ -1,14 +1,12 @@
class Party < ActiveRecord::Base
- attr_accessible :description, :end_at, :name, :user_id, :member_tokens
+ attr_accessible :description, :name, :user_id, :member_tokens
has_many :joins
has_many :members, :through => :joins, :source => :user
belongs_to :user
attr_reader :member_tokens
- validates :name, :end_at, :presence => true
-
def member_tokens=(ids)
self.member_ids = ids.split(",")
end
View
12 app/views/tasks/_task.html.haml
@@ -1,6 +1,8 @@
= content_tag_for :li, task, :class => "task" do
%p
- = task.content
+ = nl2br task.content
+ .helpme
+ = "HELP ME!!!" if task.help
- if task.state == "done"
.times
%ul
@@ -18,7 +20,11 @@
%li.hold= link_to "hold", hold_party_task_path(@party, task), :remote => true
%li.finish= link_to "finish", finish_party_task_path(@party, task), :remote => true
%p.help
- %a{:href => ""} HELP
+ = link_to help_message(task), help_party_task_path(@party, task), :remote => true
- when "backlog"
- if user_signed_in? && current_user == task.user
- %p.start= link_to "start", start_party_task_path(@party, task), :remote => true
+ %p.start= link_to "start", start_party_task_path(@party, task), :remote => true
+ %p= link_to "delete", party_task_path(@party, task), :method => :delete, :remote => true
+ - when "done"
+ - if user_signed_in? && current_user == task.user
+ %p= link_to "redo", redo_party_task_path(@party, task), :remote => true
View
1 app/views/tasks/destroy.js.erb
@@ -0,0 +1 @@
+$('#<%= dom_id(@task) %>').remove().fadeOut()
View
6 app/views/tasks/help.js.erb
@@ -0,0 +1,6 @@
+<% if @task.help %>
+$('#<%= dom_id(@task) %> .helpme').html("HELP ME!!!")
+<% else %>
+$('#<%= dom_id(@task) %> .helpme').empty()
+<% end %>
+$('#<%= dom_id(@task) %> .help a').html("<%= help_message(@task) %>")
View
2 app/views/tasks/redo.js.erb
@@ -0,0 +1,2 @@
+$('#<%= dom_id(@task) %>').remove().fadeOut()
+$('#<%= dom_id(current_user) %> .backlog ul').prepend("<%= j(render @task) %>").fadeIn()
View
6 config/routes.rb
@@ -4,9 +4,11 @@
resources :parties do
resources :tasks do
- get "start", :on => :member
- get "hold", :on => :member
+ get "start", :on => :member
+ get "hold", :on => :member
get "finish", :on => :member
+ get "help", :on => :member
+ get "redo", :on => :member
end
end
View
1 db/migrate/20120429020848_create_parties.rb
@@ -3,7 +3,6 @@ def change
create_table :parties do |t|
t.string :name
t.text :description
- t.datetime :end_at
t.integer :user_id
t.timestamps
View
4 db/migrate/20120429020930_create_joins.rb
@@ -4,6 +4,10 @@ def change
t.integer :user_id
t.integer :party_id
t.string :state, default: "chore"
+ t.datetime :started_at
+ t.datetime :finished_at
+ t.integer :end_hour, :default => 0
+ t.integer :end_min, :default => 0
t.timestamps
end
View
1 db/migrate/20120429045006_create_tasks.rb
@@ -5,6 +5,7 @@ def change
t.integer :party_id
t.text :content
t.string :state
+ t.boolean :help, dafault: false
t.datetime :started_at
t.datetime :finished_at
View
8 db/migrate/20120512083000_add_finished_at_to_joins.rb
@@ -1,8 +0,0 @@
-class AddFinishedAtToJoins < ActiveRecord::Migration
- def change
- add_column :joins, :started_at, :datetime
- add_column :joins, :finished_at, :datetime
- add_column :joins, :end_hour, :integer, default: 0
- add_column :joins, :end_min, :integer, default: 0
- end
-end
View
8 db/schema.rb
@@ -11,24 +11,23 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120512083000) do
+ActiveRecord::Schema.define(:version => 20120429045006) do
create_table "joins", :force => true do |t|
t.integer "user_id"
t.integer "party_id"
t.string "state", :default => "chore"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
t.datetime "started_at"
t.datetime "finished_at"
t.integer "end_hour", :default => 0
t.integer "end_min", :default => 0
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
end
create_table "parties", :force => true do |t|
t.string "name"
t.text "description"
- t.datetime "end_at"
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
@@ -39,6 +38,7 @@
t.integer "party_id"
t.text "content"
t.string "state"
+ t.boolean "help"
t.datetime "started_at"
t.datetime "finished_at"
t.datetime "created_at", :null => false
View
10 db/seeds.rb
@@ -6,10 +6,10 @@
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
-User.create(name: 'yoshida naoki')
+User.create(name: 'yoshida')
+User.create(name: 'machida')
User.create(name: 'yoshinao0330')
-User.create(name: 'frasel')
-Party.create(name: 'p4d hackason #1', end_at: Time.now.to_date.tomorrow)
-Party.create(name: 'p4d hackason #2', end_at: Time.now.to_date.tomorrow)
-Party.create(name: 'p4d hackason #3', end_at: Time.now.to_date.tomorrow)
+Party.create(name: 'p4d hackason #1')
+Party.create(name: 'p4d hackason #2')
+Party.create(name: 'p4d hackason #3')

0 comments on commit c22136b

Please sign in to comment.