Author: assaf
Date: Tue May 27 12:50:52 2008
New Revision: 660664
URL: http://svn.apache.org/viewvc?rev=660664&view=rev
Log:
Added following and completed tasks views.
Added:
ode/sandbox/singleshot/app/views/tasks/_task.html.erb
ode/sandbox/singleshot/app/views/tasks/by_day.html.erb
Modified:
ode/sandbox/singleshot/app/controllers/tasks_controller.rb
ode/sandbox/singleshot/app/models/task.rb
ode/sandbox/singleshot/app/views/activities/index.html.erb
ode/sandbox/singleshot/app/views/tasks/index.html.erb
ode/sandbox/singleshot/lib/tasks/populate.rake
ode/sandbox/singleshot/public/stylesheets/default.css
Modified: ode/sandbox/singleshot/app/controllers/tasks_controller.rb
URL:
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/controllers/tasks_controller.rb?rev=660664&r1=660663&r2=660664&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/controllers/tasks_controller.rb (original)
+++ ode/sandbox/singleshot/app/controllers/tasks_controller.rb Tue May 27
12:50:52 2008
@@ -1,6 +1,6 @@
class TasksController < ApplicationController
- access_key_authentication :only=>[:index, :show]
+ access_key_authentication :only=>[:index, :completed, :following, :show]
verify :params=>:task, :only=>:update, :render=>{:text=>'Missing task',
:status=>:bad_request}
before_filter :authenticate, :except=>[:show, :update, :complete, :destroy]
@@ -8,13 +8,54 @@
before_filter :forbid_reserved, :except=>[:update, :destroy]
def index
- @title = 'Tasks'
- @subtitle = 'Tasks you are performing or can claim for your own.'
+ @title, @subtitle = 'Tasks', 'Tasks you are performing or can claim for
your own.'
@alternate = { Mime::ATOM=>formatted_tasks_url(:format=>:atom,
:access_key=>authenticated.access_key),
Mime::ICS=>formatted_tasks_url(:format=>:ics,
:access_key=>authenticated.access_key) }
@tasks =
Task.pending.for_stakeholder(authenticated).with_stakeholders.rank_for(authenticated)
+ respond_to do |format|
+ format.html
+ # TODO: format.xml
+ # TODO: format.json
+ format.atom
+ format.ics
+ end
+ end
+
+ def completed
+ @title, @subtitle = 'Completed', 'Completed tasks'
+ @alternate = { Mime::ATOM=>formatted_completed_tasks_url(:format=>:atom,
:access_key=>authenticated.access_key),
+ Mime::ICS=>formatted_completed_tasks_url(:format=>:ics,
:access_key=>authenticated.access_key) }
+ @tasks = Task.completed.for_stakeholder(authenticated).with_stakeholders
+ respond_to do |format|
+ format.html do
+ @days = @tasks.group_by { |task| task.updated_at.to_date }
+ render :template=>'tasks/by_day'
+ end
+ # TODO: format.xml
+ # TODO: format.json
+ format.atom { render :action=>'index' }
+ format.ics { render :action=>'ics' }
+ end
end
+ def following
+ @title, @subtitle = 'Following', 'Tasks you created, observing or
managing.'
+ @alternate = { Mime::ATOM=>formatted_following_tasks_url(:format=>:atom,
:access_key=>authenticated.access_key),
+ Mime::ICS=>formatted_following_tasks_url(:format=>:ics,
:access_key=>authenticated.access_key) }
+ @tasks = Task.following.for_stakeholder(authenticated).with_stakeholders
+ respond_to do |format|
+ format.html do
+ @days = @tasks.group_by { |task| task.updated_at.to_date }
+ render :template=>'tasks/by_day'
+ end
+ # TODO: format.xml
+ # TODO: format.json
+ format.atom { render :action=>'index' }
+ format.ics { render :action=>'ics' }
+ end
+ end
+
+
def show
@alternate = { Mime::ICS=>formatted_tasks_url(:format=>:ics,
:access_key=>authenticated.access_key) }
respond_to do |format|
Modified: ode/sandbox/singleshot/app/models/task.rb
URL:
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/models/task.rb?rev=660664&r1=660663&r2=660664&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/models/task.rb (original)
+++ ode/sandbox/singleshot/app/models/task.rb Tue May 27 12:50:52 2008
@@ -347,14 +347,6 @@
-
-
-
-
-
-
-
-
# --- Finders and named scopes ---
# Pending tasks are:
@@ -364,4 +356,11 @@
:conditions=>["(tasks.status = 'ready' AND involved.role = 'potential') OR
(tasks.status = 'active' AND involved.role = 'owner')"],
:extend=>RankingMethods
+ named_scope :completed, lambda { |end_date|
+ { :conditions=>["tasks.status == 'completed' AND tasks.updated_at >= ?",
end_date || Date.today - 7.days],
+ :order=>'tasks.updated_at DESC' } }
+
+ named_scope :following, lambda { |end_date|
+ { :conditions=>["involved.role IN ('creator', 'observer', 'admin') AND
tasks.updated_at >= ?", end_date || Date.today - 7.days],
+ :order=>'tasks.updated_at DESC' } }
end
Modified: ode/sandbox/singleshot/app/views/activities/index.html.erb
URL:
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/views/activities/index.html.erb?rev=660664&r1=660663&r2=660664&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/views/activities/index.html.erb (original)
+++ ode/sandbox/singleshot/app/views/activities/index.html.erb Tue May 27
12:50:52 2008
@@ -1,7 +1,7 @@
<ol class='activities hfeed'>
<% for day in @days %>
<li class='day'>
- <h3><%= relative_date(day.first) %></h3>
+ <h3 class='date'><%= relative_date(day.first).titleize %></h3>
<% for activity in day.last %>
<% content_tag_for 'li', activity, :class=>'hentry entry-title' do %>
<%= link_to h(activity.person.fullname), activity.person.identity %>
Added: ode/sandbox/singleshot/app/views/tasks/_task.html.erb
URL:
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/views/tasks/_task.html.erb?rev=660664&view=auto
==============================================================================
--- ode/sandbox/singleshot/app/views/tasks/_task.html.erb (added)
+++ ode/sandbox/singleshot/app/views/tasks/_task.html.erb Tue May 27 12:50:52
2008
@@ -0,0 +1,7 @@
+<div class='actions'><%= quick_actions(task) %></div>
+<h3 class='entry-title priority_<%= task.priority %> <%= 'overdue' if
task.over_due? %>'>
+ <%= link_to h(task.title), task_url(task), :rel=>'bookmark',
:title=>'View/perform task' %></h3>
+<div class='entry-content'>
+ <p class='description'><%= truncate(strip_tags(task.description), 500) %></p>
+ <p class='vitals'><%= task_vitals(task) %></p>
+</div>
Added: ode/sandbox/singleshot/app/views/tasks/by_day.html.erb
URL:
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/views/tasks/by_day.html.erb?rev=660664&view=auto
==============================================================================
--- ode/sandbox/singleshot/app/views/tasks/by_day.html.erb (added)
+++ ode/sandbox/singleshot/app/views/tasks/by_day.html.erb Tue May 27 12:50:52
2008
@@ -0,0 +1,13 @@
+<ol class='tasks hfeed'>
+ <% for day in @days %>
+ <li class='date'><h2><%= relative_date(day.first).titleize %></h2>
+ <ol>
+ <% for task in day.last %>
+ <% content_tag_for 'li', task, :class=>'hentry' do %>
+ <%= render :partial=>'task', :locals=>{ :task=>task } %>
+ <% end %>
+ <% end %>
+ </ol>
+ </li>
+ <% end %>
+</ol>
Modified: ode/sandbox/singleshot/app/views/tasks/index.html.erb
URL:
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/views/tasks/index.html.erb?rev=660664&r1=660663&r2=660664&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/views/tasks/index.html.erb (original)
+++ ode/sandbox/singleshot/app/views/tasks/index.html.erb Tue May 27 12:50:52
2008
@@ -1,14 +1,7 @@
-<% @title = 'Tasks' %>
<ol class='tasks hfeed'>
<% @tasks.each do |task| %>
<% content_tag_for 'li', task, :class=>'hentry' do %>
- <div class='actions'><%= quick_actions(task) %></div>
- <h3 class='entry-title priority_<%= task.priority %> <%= 'overdue' if
task.over_due? %>'>
- <%= link_to h(task.title), task_url(task), :rel=>'bookmark',
:title=>'View/perform task' %></h3>
- <div class='entry-content'>
- <p class='description'><%= truncate(strip_tags(task.description), 500)
%></p>
- <p class='vitals'><%= task_vitals(task) %></p>
- </div>
+ <%= render :partial=>'task', :locals=>{ :task=>task } %>
<% end %>
<% end %>
</ol>
Modified: ode/sandbox/singleshot/lib/tasks/populate.rake
URL:
http://svn.apache.org/viewvc/ode/sandbox/singleshot/lib/tasks/populate.rake?rev=660664&r1=660663&r2=660664&view=diff
==============================================================================
--- ode/sandbox/singleshot/lib/tasks/populate.rake (original)
+++ ode/sandbox/singleshot/lib/tasks/populate.rake Tue May 27 12:50:52 2008
@@ -37,7 +37,9 @@
you = Person.find_by_identity(ENV['USER'])
defaults = { :title=>Faker::Lorem.sentence,
:description=>Faker::Lorem.paragraphs(3).join("\n\n"),
:frame_url=>'http://localhost:3001/sandwich',
:potential_owners=>[you, other] }
- Task.new(defaults.merge(attributes || {})).modified_by(you).save!
+ returning Task.new(defaults.merge(attributes || {})) do |task|
+ task.modified_by(you).save!
+ end
end
@@ -62,6 +64,10 @@
create :owner=>you, :due_on=>Time.today - 1.day
create :owner=>you, :due_on=>Time.today
create :owner=>you, :due_on=>Time.today + 1.day
+ # Completed, cancelled
+ task = create(:owner=>you)
+ task.status = 'completed'
+ task.save
end
end
Modified: ode/sandbox/singleshot/public/stylesheets/default.css
URL:
http://svn.apache.org/viewvc/ode/sandbox/singleshot/public/stylesheets/default.css?rev=660664&r1=660663&r2=660664&view=diff
==============================================================================
--- ode/sandbox/singleshot/public/stylesheets/default.css (original)
+++ ode/sandbox/singleshot/public/stylesheets/default.css Tue May 27 12:50:52
2008
@@ -225,6 +225,14 @@
#main ol.tasks li.task p.vitals {
color: #808080;
}
+#main ol.tasks li.date h2 {
+ font-size: 1.4em;
+}
+#main ol.tasks li.date ol {
+ list-style: none;
+ margin: 0;
+ padding: 0;
+}
/** Activities **/