Author: assaf
Date: Sat May 17 00:30:58 2008
New Revision: 657302

URL: http://svn.apache.org/viewvc?rev=657302&view=rev
Log:
Moved task activity rendering to activities controller, where it belongs.

Added:
    ode/sandbox/singleshot/app/views/activities/index.atom.builder
      - copied, changed from r657254, 
ode/sandbox/singleshot/app/views/activities/show.atom.builder
    ode/sandbox/singleshot/app/views/activities/index.html.erb
      - copied, changed from r657254, 
ode/sandbox/singleshot/app/views/activities/show.html.erb
    ode/sandbox/singleshot/app/views/activities/index.ics.ical
      - copied, changed from r657254, 
ode/sandbox/singleshot/app/views/activities/show.ics.ical
Removed:
    ode/sandbox/singleshot/app/views/activities/show.atom.builder
    ode/sandbox/singleshot/app/views/activities/show.html.erb
    ode/sandbox/singleshot/app/views/activities/show.ics.ical
Modified:
    ode/sandbox/singleshot/app/controllers/activities_controller.rb
    ode/sandbox/singleshot/app/controllers/tasks_controller.rb
    ode/sandbox/singleshot/app/models/activity.rb
    ode/sandbox/singleshot/app/models/task.rb
    ode/sandbox/singleshot/app/views/layouts/application.html.erb
    ode/sandbox/singleshot/app/views/tasks/show.html.erb
    ode/sandbox/singleshot/config/routes.rb
    ode/sandbox/singleshot/db/schema.rb

Modified: ode/sandbox/singleshot/app/controllers/activities_controller.rb
URL: 
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/controllers/activities_controller.rb?rev=657302&r1=657301&r2=657302&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/controllers/activities_controller.rb (original)
+++ ode/sandbox/singleshot/app/controllers/activities_controller.rb Sat May 17 
00:30:58 2008
@@ -1,11 +1,12 @@
 class ActivitiesController < ApplicationController
 
-  access_key_authentication :only=>[:show]
+  access_key_authentication :only=>[:index, :show]
+  instance :task, :only=>[:show]
 
-  def show
+  def index
     @title = 'Activities'
-    @alternate = { Mime::ATOM=>formatted_activity_url(:format=>:atom, 
:access_key=>authenticated.access_key),
-                   Mime::ICS=>formatted_activity_url(:format=>:ics, 
:access_key=>authenticated.access_key) }
+    @alternate = { Mime::ATOM=>formatted_activities_url(:format=>:atom, 
:access_key=>authenticated.access_key),
+                   Mime::ICS=>formatted_activities_url(:format=>:ics, 
:access_key=>authenticated.access_key) }
     @activities = Activity.for_stakeholder(authenticated)
     day = Date.new(params[:year].to_i, params[:month].to_i, params[:day].to_i) 
rescue nil if params[:year]
     dates = day ? day..day + 1.day : Date.today - 3.day..Date.today + 1.day
@@ -17,4 +18,19 @@
     end
   end
 
+  def show
+    @title = "Activities &mdash; [EMAIL PROTECTED]"
+    @alternate = { Mime::ATOM=>formatted_activity_url(@task, :atom, 
:access_key=>authenticated.access_key),
+                   Mime::ICS=>formatted_activity_url(@task, :ics, 
:access_key=>authenticated.access_key) }
+    @activities = @task.activities
+    respond_to do |want|
+      want.html do
+        @days = @activities.group_by_day
+        render :action=>'index'
+      end
+      want.atom { render :action=>'index' }
+      want.ics  { render :action=>'index' }
+    end
+  end
+
 end

Modified: ode/sandbox/singleshot/app/controllers/tasks_controller.rb
URL: 
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/controllers/tasks_controller.rb?rev=657302&r1=657301&r2=657302&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/controllers/tasks_controller.rb (original)
+++ ode/sandbox/singleshot/app/controllers/tasks_controller.rb Sat May 17 
00:30:58 2008
@@ -1,10 +1,10 @@
 class TasksController < ApplicationController
 
-  access_key_authentication :only=>[:index, :activity]
+  access_key_authentication :only=>[:index, :show]
 
   verify :params=>:task, :only=>:update, :render=>{:text=>'Missing task', 
:status=>:bad_request}
   before_filter :authenticate, :except=>[:show, :update, :complete, :destroy]
-  instance :task, :only=>[:show, :activity, :update, :complete, :destroy], 
:check=>:instance_accessible
+  instance :task, :only=>[:show, :update, :complete, :destroy], 
:check=>:instance_accessible
   before_filter :forbid_reserved, :except=>[:update, :destroy]
 
   def index
@@ -16,30 +16,13 @@
   def show
     @alternate = { Mime::ICS=>formatted_tasks_url(:format=>:ics, 
:access_key=>authenticated.access_key) }
     respond_to do |format|
-      format.html do
-        @activities = Activity.for_task(@task)
-        render :layout=>'head'
-      end
+      format.html { render :layout=>'head' }
       format.xml  { render :xml=>@task }
       format.json { render :json=>@task }
       format.ics  do
         @tasks = [EMAIL PROTECTED]
-        #render :action=>'index'
-      end
-    end
-  end
-
-  def activity
-    @title = "Activities &mdash; [EMAIL PROTECTED]"
-    @alternate = { Mime::ATOM=>formatted_activity_task_url(@task, :atom, 
:access_key=>authenticated.access_key),
-                   Mime::ICS=>formatted_activity_task_url(@task, :ics, 
:access_key=>authenticated.access_key) }
-    @activities = Activity.for_task(@task)
-    respond_to do |want|
-      want.html do
-        @days = @activities.group_by_day
-        render :template=>'activities/show'
+        render :action=>'index'
       end
-      want.any { render :template=>'activities/show' }
     end
   end
 

Modified: ode/sandbox/singleshot/app/models/activity.rb
URL: 
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/models/activity.rb?rev=657302&r1=657301&r2=657302&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/models/activity.rb (original)
+++ ode/sandbox/singleshot/app/models/activity.rb Sat May 17 00:30:58 2008
@@ -50,7 +50,5 @@
       :include=>[:task, :person], :order=>'activities.created_at DESC', 
:extend=>GroupByDay } }
   named_scope :for_dates,
     lambda { |dates| { :conditions=>{ :created_at=>dates } } }
-  named_scope :for_task,
-    lambda { |task| { :conditions=>{ :task_id=>task }, :include=>[:task, 
:person], :order=>'activities.created_at', :extend=>GroupByDay } }
 
 end

Modified: ode/sandbox/singleshot/app/models/task.rb
URL: 
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/models/task.rb?rev=657302&r1=657301&r2=657302&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/models/task.rb (original)
+++ ode/sandbox/singleshot/app/models/task.rb Sat May 17 00:30:58 2008
@@ -179,20 +179,20 @@
 
 
   # --- Activities ---
+ 
+  has_many :activities, :include=>[:task, :person], 
:order=>'activities.created_at', :extend=>Activity::GroupByDay
 
   after_save do |task|
-    task.activities =  Activity.from_changes_to(task) unless task.state == 
'reserved'
+    task.activities.push Activity.from_changes_to(task) unless task.state == 
'reserved'
   end
 
-  attr_accessor :activities
-
   def save(person = nil)
     super
-    activities.each do |activity|
+    activities.select(&:new_record?).each do |activity|
       activity.task = self
       activity.person ||= person
       activity.save if activity.person
-    end if activities
+    end
   end
 
  

Copied: ode/sandbox/singleshot/app/views/activities/index.atom.builder (from 
r657254, ode/sandbox/singleshot/app/views/activities/show.atom.builder)
URL: 
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/views/activities/index.atom.builder?p2=ode/sandbox/singleshot/app/views/activities/index.atom.builder&p1=ode/sandbox/singleshot/app/views/activities/show.atom.builder&r1=657254&r2=657302&rev=657302&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/views/activities/show.atom.builder (original)
+++ ode/sandbox/singleshot/app/views/activities/index.atom.builder Sat May 17 
00:30:58 2008
@@ -1,4 +1,4 @@
-atom_feed :root_url=>activity_url do |feed|
+atom_feed :root_url=>activities_url do |feed|
   feed.title 'Singleshot: Activities'
   feed.updated @activities.first.created_at
 

Copied: ode/sandbox/singleshot/app/views/activities/index.html.erb (from 
r657254, ode/sandbox/singleshot/app/views/activities/show.html.erb)
URL: 
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/views/activities/index.html.erb?p2=ode/sandbox/singleshot/app/views/activities/index.html.erb&p1=ode/sandbox/singleshot/app/views/activities/show.html.erb&r1=657254&r2=657302&rev=657302&view=diff
==============================================================================
    (empty)

Copied: ode/sandbox/singleshot/app/views/activities/index.ics.ical (from 
r657254, ode/sandbox/singleshot/app/views/activities/show.ics.ical)
URL: 
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/views/activities/index.ics.ical?p2=ode/sandbox/singleshot/app/views/activities/index.ics.ical&p1=ode/sandbox/singleshot/app/views/activities/show.ics.ical&r1=657254&r2=657302&rev=657302&view=diff
==============================================================================
    (empty)

Modified: ode/sandbox/singleshot/app/views/layouts/application.html.erb
URL: 
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/views/layouts/application.html.erb?rev=657302&r1=657301&r2=657302&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/views/layouts/application.html.erb (original)
+++ ode/sandbox/singleshot/app/views/layouts/application.html.erb Sat May 17 
00:30:58 2008
@@ -20,7 +20,7 @@
         <li><%= link_to '➠ Tasks', tasks_url %></li>
         <li><%= link_to 'Following', following_tasks_url %></a></li>
         <li><%= link_to 'Completed', completed_tasks_url %></a></li>
-        <li><%= link_to 'Activity', activity_url %></a></li>
+        <li><%= link_to 'Activity', activities_url %></a></li>
         <li><a href='#'>Start &hellip;</a></li>
       </ul>
       <ul class='alternate'>

Modified: ode/sandbox/singleshot/app/views/tasks/show.html.erb
URL: 
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/views/tasks/show.html.erb?rev=657302&r1=657301&r2=657302&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/views/tasks/show.html.erb (original)
+++ ode/sandbox/singleshot/app/views/tasks/show.html.erb Sat May 17 00:30:58 
2008
@@ -7,8 +7,10 @@
     <div class='actions'><%= task_actions(@task) %> <%= link_to_function 'More 
Options', "Singleshot.expand(event, 'expanded')", :class=>'button-to' %></div>
   </div>
   <div id='expanded' style='display:none'>
-    <%= link_to image_tag('calendar.png') + ' Calendar', 
formatted_task_url(@task, 'ics'), :rel=>'alternate', :title=>'Add this task to 
your calendar' %>
-    <%= link_to image_tag('feed.png') + ' Activities', 
activity_task_url(@task), :rel=>'alternate', :title=>'Subscribe to see changes 
to this task' %>
+    <%= link_to image_tag('calendar.png') + ' Calendar', 
formatted_task_url(@task, 'ics', :access_key=>authenticated.access_key),
+                :rel=>'alternate', :title=>'Add this task to your calendar' %>
+    <%= link_to image_tag('feed.png') + ' Activities', 
formatted_activity_url(@task, 'atom', :access_key=>authenticated.access_key),
+                :rel=>'alternate', :title=>'Subscribe to see changes to this 
task' %>
     <dl>
       <dt>Task</dt><dd><%= h(@task.title) %></dd>
       <dt>Description</dt><dd><%= h(@task.description) %></dd>
@@ -16,7 +18,7 @@
       <dt>Recent activity</dt>
       <dd>
         <ol class='activities hfeed'>
-          <% for activity in @activities %>
+          <% for activity in @task.activities %>
             <% content_tag_for 'li', activity, :class=>'hentry entry-title' do 
%>
               <%= link_to activity.person.fullname, activity.person.identity %>
               <%= activity.action %>

Modified: ode/sandbox/singleshot/config/routes.rb
URL: 
http://svn.apache.org/viewvc/ode/sandbox/singleshot/config/routes.rb?rev=657302&r1=657301&r2=657302&view=diff
==============================================================================
--- ode/sandbox/singleshot/config/routes.rb (original)
+++ ode/sandbox/singleshot/config/routes.rb Sat May 17 00:30:58 2008
@@ -2,7 +2,7 @@
 
   map.resource 'session'
   map.resources 'tasks', :collection=>{ 'following'=>:get, 'completed'=>:get 
}, :member=>{ 'activity'=>:get }
-  map.resource 'activity'
+  map.resources 'activities'
   map.day_activity 'activity/:year/:month/:day', :controller=>'activities', 
:action=>'show', :year =>/\d{4}/, :month=>/\d{1,2}/, :day=>/\d{1,2}/
   map.root :controller=>'tasks'
   map.resource 'sandwich'

Modified: ode/sandbox/singleshot/db/schema.rb
URL: 
http://svn.apache.org/viewvc/ode/sandbox/singleshot/db/schema.rb?rev=657302&r1=657301&r2=657302&view=diff
==============================================================================
--- ode/sandbox/singleshot/db/schema.rb (original)
+++ ode/sandbox/singleshot/db/schema.rb Sat May 17 00:30:58 2008
@@ -30,10 +30,10 @@
     t.datetime "updated_at"
   end
 
-  add_index "people", ["access_key"], :name => "index_people_on_access_key", 
:unique => true
-  add_index "people", ["email"], :name => "index_people_on_email", :unique => 
true
-  add_index "people", ["fullname"], :name => "index_people_on_fullname"
   add_index "people", ["identity"], :name => "index_people_on_identity", 
:unique => true
+  add_index "people", ["fullname"], :name => "index_people_on_fullname"
+  add_index "people", ["email"], :name => "index_people_on_email", :unique => 
true
+  add_index "people", ["access_key"], :name => "index_people_on_access_key", 
:unique => true
 
   create_table "stakeholders", :force => true do |t|
     t.integer  "task_id",    :null => false
@@ -43,9 +43,9 @@
     t.datetime "updated_at"
   end
 
-  add_index "stakeholders", ["person_id", "role"], :name => 
"index_stakeholders_on_person_id_and_role"
-  add_index "stakeholders", ["task_id", "role"], :name => 
"index_stakeholders_on_task_id_and_role"
   add_index "stakeholders", ["task_id", "person_id", "role"], :name => 
"index_stakeholders_on_task_id_and_person_id_and_role", :unique => true
+  add_index "stakeholders", ["task_id", "role"], :name => 
"index_stakeholders_on_task_id_and_role"
+  add_index "stakeholders", ["person_id", "role"], :name => 
"index_stakeholders_on_person_id_and_role"
 
   create_table "tasks", :force => true do |t|
     t.string   "title",                                     :null => false


Reply via email to