Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
425 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Place all the behaviors and hooks related to the matching controller here. | ||
# All this logic will automatically be available in application.js. | ||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
body { | ||
background-color: #fff; | ||
color: #333; | ||
font-family: verdana, arial, helvetica, sans-serif; | ||
font-size: 13px; | ||
line-height: 18px; } | ||
|
||
p, ol, ul, td { | ||
font-family: verdana, arial, helvetica, sans-serif; | ||
font-size: 13px; | ||
line-height: 18px; } | ||
|
||
pre { | ||
background-color: #eee; | ||
padding: 10px; | ||
font-size: 11px; } | ||
|
||
a { | ||
color: #000; | ||
&:visited { | ||
color: #666; } | ||
&:hover { | ||
color: #fff; | ||
background-color: #000; } } | ||
|
||
div { | ||
&.field, &.actions { | ||
margin-bottom: 10px; } } | ||
|
||
#notice { | ||
color: green; } | ||
|
||
.field_with_errors { | ||
padding: 2px; | ||
background-color: red; | ||
display: table; } | ||
|
||
#error_explanation { | ||
width: 450px; | ||
border: 2px solid red; | ||
padding: 7px; | ||
padding-bottom: 0; | ||
margin-bottom: 20px; | ||
background-color: #f0f0f0; | ||
h2 { | ||
text-align: left; | ||
font-weight: bold; | ||
padding: 5px 5px 5px 15px; | ||
font-size: 12px; | ||
margin: -7px; | ||
margin-bottom: 0px; | ||
background-color: #c00; | ||
color: #fff; } | ||
ul li { | ||
font-size: 12px; | ||
list-style: square; } } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Place all the styles related to the Tasks controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
class TasksController < ApplicationController | ||
before_filter :authenticate_user!, :except => [:index, :show] | ||
|
||
# GET /tasks | ||
# GET /tasks.json | ||
def index | ||
@tasks = Task.all | ||
|
||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.json { render json: @tasks } | ||
end | ||
end | ||
|
||
# GET /tasks/1 | ||
# GET /tasks/1.json | ||
def show | ||
@task = Task.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.html # show.html.erb | ||
format.json { render json: @task } | ||
end | ||
end | ||
|
||
# GET /tasks/new | ||
# GET /tasks/new.json | ||
def new | ||
@task = Task.new | ||
|
||
respond_to do |format| | ||
format.html # new.html.erb | ||
format.json { render json: @task } | ||
end | ||
end | ||
|
||
# GET /tasks/1/edit | ||
def edit | ||
@task = Task.find(params[:id]) | ||
end | ||
|
||
# POST /tasks | ||
# POST /tasks.json | ||
def create | ||
@task = Task.new(params[:task]) | ||
@task.user_id = current_user.id | ||
@task.party_id = params[:party_id] | ||
@task.state = "backlog" | ||
|
||
respond_to do |format| | ||
if @task.save | ||
format.html { redirect_to @task.party, notice: 'Task was successfully created.' } | ||
format.json { render json: @task, status: :created, location: @task } | ||
else | ||
format.html { render action: "new" } | ||
format.json { render json: @task.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PUT /tasks/1 | ||
# PUT /tasks/1.json | ||
def update | ||
@task = Task.find(params[:id]) | ||
|
||
respond_to do |format| | ||
if @task.update_attributes(params[:task]) | ||
format.html { redirect_to @task, notice: 'Task was successfully updated.' } | ||
format.json { head :no_content } | ||
else | ||
format.html { render action: "edit" } | ||
format.json { render json: @task.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# 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 start | ||
raise params | ||
end | ||
|
||
def hold | ||
raise params | ||
end | ||
|
||
def finish | ||
raise params | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module TasksHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class Task < ActiveRecord::Base | ||
attr_accessible :content, :end_time, :start_time, :state, :user_id | ||
belongs_to :user | ||
belongs_to :party | ||
|
||
scope :current, where(state: "current") | ||
scope :backlog, where(state: "backlog").order("created_at desc") | ||
scope :done, where(state: "done").order("created_at desc") | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<%= form_for(@task) do |f| %> | ||
<% if @task.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(@task.errors.count, "error") %> prohibited this task from being saved:</h2> | ||
|
||
<ul> | ||
<% @task.errors.full_messages.each do |msg| %> | ||
<li><%= msg %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div class="field"> | ||
<%= f.label :user_id %><br /> | ||
<%= f.number_field :user_id %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :content %><br /> | ||
<%= f.text_area :content %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :state %><br /> | ||
<%= f.text_field :state %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :start_time %><br /> | ||
<%= f.time_select :start_time %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :end_time %><br /> | ||
<%= f.time_select :end_time %> | ||
</div> | ||
<div class="actions"> | ||
<%= f.submit %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<h1>Editing task</h1> | ||
|
||
<%= render 'form' %> | ||
<%= link_to 'Show', @task %> | | ||
<%= link_to 'Back', tasks_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<h1>Listing tasks</h1> | ||
|
||
<table> | ||
<tr> | ||
<th>User</th> | ||
<th>Content</th> | ||
<th>State</th> | ||
<th>Start time</th> | ||
<th>End time</th> | ||
<th></th> | ||
<th></th> | ||
<th></th> | ||
</tr> | ||
|
||
<% @tasks.each do |task| %> | ||
<tr> | ||
<td><%= task.user_id %></td> | ||
<td><%= task.content %></td> | ||
<td><%= task.state %></td> | ||
<td><%= task.start_time %></td> | ||
<td><%= task.end_time %></td> | ||
<td><%= link_to 'Show', task %></td> | ||
<td><%= link_to 'Edit', edit_task_path(task) %></td> | ||
<td><%= link_to 'Destroy', task, confirm: 'Are you sure?', method: :delete %></td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
|
||
<br /> | ||
|
||
<%= link_to 'New Task', new_task_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<h1>New task</h1> | ||
|
||
<%= render 'form' %> | ||
<%= link_to 'Back', tasks_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<p> | ||
<b>User:</b> | ||
<%= @task.user_id %> | ||
</p> | ||
|
||
<p> | ||
<b>Content:</b> | ||
<%= @task.content %> | ||
</p> | ||
|
||
<p> | ||
<b>State:</b> | ||
<%= @task.state %> | ||
</p> | ||
|
||
<p> | ||
<b>Start time:</b> | ||
<%= @task.start_time %> | ||
</p> | ||
|
||
<p> | ||
<b>End time:</b> | ||
<%= @task.end_time %> | ||
</p> | ||
|
||
|
||
<%= link_to 'Edit', edit_task_path(@task) %> | | ||
<%= link_to 'Back', tasks_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class CreateTasks < ActiveRecord::Migration | ||
def change | ||
create_table :tasks do |t| | ||
t.integer :user_id | ||
t.integer :party_id | ||
t.text :content | ||
t.string :state | ||
t.time :start_time | ||
t.time :end_time | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
Oops, something went wrong.